Environment.FailFast Метод
Определение
Завершает процесс сразу после записи сообщения в журнал событий приложений Windows, после чего включает сообщение и дополнительные сведения об исключении в отчет об ошибках, отправляемый в корпорацию Майкрософт.Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message and optional exception information in error reporting to Microsoft.
Перегрузки
FailFast(String) |
Завершает процесс сразу после записи сообщения в журнал событий приложений Windows, после чего включает сообщение в отчет об ошибках, отправляемый в корпорацию Майкрософт.Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message in error reporting to Microsoft. |
FailFast(String, Exception) |
Завершает процесс сразу после записи сообщения в журнал событий приложений Windows, после чего включает сообщение и сведения об исключении в отчет об ошибках, отправляемый в корпорацию Майкрософт.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. |
FailFast(String)
Завершает процесс сразу после записи сообщения в журнал событий приложений Windows, после чего включает сообщение в отчет об ошибках, отправляемый в корпорацию Майкрософт.Immediately terminates a process after writing a message to the Windows Application event log, and then includes the message in error reporting to Microsoft.
public:
static void FailFast(System::String ^ message);
[System.Security.SecurityCritical]
public static void FailFast (string message);
public static void FailFast (string? message);
public static void FailFast (string message);
[<System.Security.SecurityCritical>]
static member FailFast : string -> unit
static member FailFast : string -> unit
Public Shared Sub FailFast (message As String)
Параметры
- message
- String
Сообщение, в котором объясняется причина завершения процесса или содержится значение null
, если объяснение отсутствует.A message that explains why the process was terminated, or null
if no explanation is provided.
- Атрибуты
Примеры
В следующем примере запись журнала записывается в журнал событий приложений Windows и завершает текущий процесс.The following example writes a log entry to the Windows Application event log and terminates the current process.
using System;
class Example
{
public static void Main()
{
string causeOfFailure = "A catastrophic failure has occurred.";
// Assume your application has failed catastrophically and must
// terminate immediately. The try-finally block is not executed
// and is included only to demonstrate that instructions within
// try-catch blocks and finalizers are not performed.
try
{
Environment.FailFast(causeOfFailure);
}
finally
{
Console.WriteLine("This finally block will not be executed.");
}
}
}
/*
The example produces no output because the application is terminated.
However, an entry is made in the Windows Application event log, and
the log entry contains the text from the causeOfFailure variable.
*/
Module Example
Public Sub Main()
Dim causeOfFailure As String = "A catastrophic failure has occurred."
' Assume your application has failed catastrophically and must
' terminate immediately. The try-finally block is not executed
' and is included only to demonstrate that instructions within
' try-catch blocks and finalizers are not performed.
Try
Environment.FailFast(causeOfFailure)
Finally
Console.WriteLine("This finally block will not be executed.")
End Try
End Sub
End Module
'
' The code example displays no output because the application is
' terminated. However, an entry is made in the Windows Application event
' log, and the log entry contains the text from the causeOfFailure variable.
Комментарии
Этот метод завершает процесс без выполнения каких-либо активных try
/ finally
блоков или методов завершения.This method terminates a process without running any active try
/finally
blocks or finalizers.
Environment.FailFast
Метод записывает message
строку в журнал событий приложений Windows, создает дамп приложения, а затем завершает текущий процесс.The Environment.FailFast
method writes the message
string to the Windows Application event log, creates a dump of your application, and then terminates the current process. message
Строка также включается в отчеты об ошибках в корпорацию Майкрософт.The message
string is also included in error reporting to Microsoft.
Используйте Environment.FailFast
метод вместо Exit метода, чтобы завершить работу приложения, если состояние приложения повреждено после восстановления, и выполнение try
/ finally
блоков и методов завершения приложения приведет к повреждению ресурсов программы.Use the Environment.FailFast
method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair, and executing your application's try
/finally
blocks and finalizers will corrupt program resources.
Сведения выводятся в корпорацию Майкрософт с помощью отчеты об ошибках Windows.Information is reported to Microsoft by using Windows Error Reporting. Дополнительные сведения см. в разделе отчеты об ошибках Windows: Начало работы.For more information, see Windows Error Reporting: Getting Started.
Вызов Environment.FailFast
метода для завершения выполнения приложения, выполняющегося в отладчике Visual Studio, вызывает исключение ExecutionEngineException и автоматически запускает помощник по отладке управляемого кода (MDA) фаталексекутионенгиниррор.Calling the Environment.FailFast
method to terminate execution of an application running in the Visual Studio debugger throws an ExecutionEngineException and automatically triggers the fatalExecutionEngineError managed debugging assistant (MDA).
Применяется к
FailFast(String, Exception)
Завершает процесс сразу после записи сообщения в журнал событий приложений Windows, после чего включает сообщение и сведения об исключении в отчет об ошибках, отправляемый в корпорацию Майкрософт.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.
public:
static void FailFast(System::String ^ message, Exception ^ exception);
[System.Security.SecurityCritical]
public static void FailFast (string message, Exception exception);
public static void FailFast (string? message, Exception? exception);
public static void FailFast (string message, Exception exception);
[<System.Security.SecurityCritical>]
static member FailFast : string * Exception -> unit
static member FailFast : string * Exception -> unit
Public Shared Sub FailFast (message As String, exception As Exception)
Параметры
- message
- String
Сообщение, в котором объясняется причина завершения процесса или содержится значение null
, если объяснение отсутствует.A message that explains why the process was terminated, or null
if no explanation is provided.
- exception
- Exception
Исключение, представляющее ошибку, вызвавшую завершение процесса.An exception that represents the error that caused the termination. Обычно это исключение в блоке catch
.This is typically the exception in a catch
block.
- Атрибуты
Комментарии
Этот метод завершает процесс без выполнения каких try
/ finally
либо активных блоков или методов завершения.This method terminates the process without running any active try
/finally
blocks or finalizers.
Environment.FailFast
Метод записывает message
строку в журнал событий приложений Windows, создает дамп приложения, а затем завершает текущий процесс.The Environment.FailFast
method writes the message
string to the Windows Application event log, creates a dump of your application, and then terminates the current process.
Сведения выводятся в корпорацию Майкрософт с помощью отчеты об ошибках Windows.Information is reported to Microsoft by using Windows Error Reporting. Дополнительные сведения см. в разделе отчеты об ошибках Windows: Начало работы.For more information, see Windows Error Reporting: Getting Started. Отчеты об ошибках, включаемые в корпорацию Майкрософт, содержат сведения message
exception
, используемые для классификации ошибки.Error reporting to Microsoft includes message
and exception
information, which provides details used to classify the error. Хотя exception
не обрабатывается, поскольку процесс завершается, контекстные сведения, вызвавшие исключение, по-прежнему получаются.Although exception
is not handled because the process is terminated, the contextual information that raised the exception is still obtained.
Если exception
имеет значение null
или если exception
не возникает исключение, этот метод действует так же, как FailFast(String) перегрузка метода.If exception
is null
, or if exception
is not thrown, this method operates the same as the FailFast(String) method overload.
Используйте Environment.FailFast
метод вместо Exit метода, чтобы завершить работу приложения, если состояние приложения повреждено после восстановления, и выполнение try
/ finally
блоков и методов завершения приложения приведет к повреждению ресурсов программы.Use the Environment.FailFast
method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair, and executing your application's try
/finally
blocks and finalizers will corrupt program resources.
Вызов Environment.FailFast
метода для завершения выполнения приложения, выполняющегося в отладчике Visual Studio, вызывает исключение ExecutionEngineException и автоматически запускает помощник по отладке управляемого кода (MDA) фаталексекутионенгиниррор.Calling the Environment.FailFast
method to terminate execution of an application running in the Visual Studio debugger throws an ExecutionEngineException and automatically triggers the fatalExecutionEngineError managed debugging assistant (MDA).