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.