C# Environment FailFast(String)

Description

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

Syntax

Environment.FailFast(String) has the following syntax.


public static void FailFast(
  string message
)

Parameters

Environment.FailFast(String) has the following parameters.

  • message - A message that explains why the process was terminated, or null if no explanation is provided.

Returns

Environment.FailFast(String) method returns

Example

The following example writes a log entry to the Windows Application event log and terminates the current process.


/*  w ww  .jav a 2 s .c o  m*/

using System;

class Sample 
{
    public static void Main() 
    {
        string causeOfFailure = "A failure has occured.";
    
        try {
            Environment.FailFast(causeOfFailure);
        }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