C# Environment FailFast(String, Exception)

Description

Environment FailFast(String, Exception) immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and exception information in error reporting to Microsoft.

Syntax

Environment.FailFast(String, Exception) has the following syntax.


public static void FailFast(
  string message,
  Exception exception
)

Parameters

Environment.FailFast(String, Exception) has the following parameters.

  • message - A message that explains why the process was terminated, or null if no explanation is provided.
  • exception - An exception that represents the error that caused the termination. This is typically the exception in a catch block.

Returns

Environment.FailFast(String, Exception) method returns

Example


//w ww .ja v a  2 s . co m
using System;

class Sample 
{
    public static void Main() 
    {
        string causeOfFailure = "A failure has occured.";
    
        try {
            Environment.FailFast(causeOfFailure,new Exception());
        }finally{
            Console.WriteLine("This finally block will not be executed.");
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version