Environment.FailFast Método
Definición
Finaliza inmediatamente un proceso después de escribir un mensaje en el registro de eventos de la aplicación Windows y, después, incluye el mensaje y la información de excepción opcional en el informe de errores que se envía a Microsoft.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.
Sobrecargas
FailFast(String) |
Finaliza inmediatamente un proceso después de escribir un mensaje en el registro de eventos de la aplicación Windows y, después, incluye el mensaje en el informe de errores que se envía a Microsoft.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) |
Finaliza inmediatamente un proceso después de escribir un mensaje en el registro de eventos de la aplicación Windows y, luego, incluye el mensaje y la información de excepción en el informe de errores que se envía a Microsoft.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)
Finaliza inmediatamente un proceso después de escribir un mensaje en el registro de eventos de la aplicación Windows y, después, incluye el mensaje en el informe de errores que se envía a Microsoft.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)
Parámetros
- message
- String
Mensaje que explica por qué finalizó el proceso o null
si no se proporciona ninguna explicación.A message that explains why the process was terminated, or null
if no explanation is provided.
- Atributos
Ejemplos
En el ejemplo siguiente se escribe una entrada de registro en el registro de eventos de aplicación Windows y finaliza el proceso actual.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.
Comentarios
Este método finaliza un proceso sin ejecutar ningún try
/ finally
bloque o finalizador activo.This method terminates a process without running any active try
/finally
blocks or finalizers.
El Environment.FailFast
método escribe la message
cadena en el registro de eventos de aplicación Windows, crea un volcado de memoria de la aplicación y, a continuación, finaliza el proceso actual.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. La message
cadena también se incluye en el informe de errores de Microsoft.The message
string is also included in error reporting to Microsoft.
Utilice el Environment.FailFast
método en lugar del Exit método para finalizar la aplicación si el estado de la aplicación está dañado más allá de la reparación y la ejecución de los try
/ finally
bloques y finalizadores de la aplicación dañará los recursos del programa.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.
La información se envía a Microsoft mediante Informe de errores de Windows.Information is reported to Microsoft by using Windows Error Reporting. Para obtener más información, vea Informe de errores de Windows: Introducción.For more information, see Windows Error Reporting: Getting Started.
Al llamar al Environment.FailFast
método para finalizar la ejecución de una aplicación que se ejecuta en el depurador de Visual Studio, se produce una excepción ExecutionEngineException y se desencadena automáticamente el Asistente para la depuración administrada (MDA) fatalexecutionerror.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).
Se aplica a
FailFast(String, Exception)
Finaliza inmediatamente un proceso después de escribir un mensaje en el registro de eventos de la aplicación Windows y, luego, incluye el mensaje y la información de excepción en el informe de errores que se envía a Microsoft.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)
Parámetros
- message
- String
Mensaje que explica por qué finalizó el proceso o null
si no se proporciona ninguna explicación.A message that explains why the process was terminated, or null
if no explanation is provided.
- exception
- Exception
Una excepción que representa el error que causó la finalización.An exception that represents the error that caused the termination. Esta es normalmente la excepción en un bloque catch
.This is typically the exception in a catch
block.
- Atributos
Comentarios
Este método finaliza el proceso sin ejecutar ningún try
/ finally
bloque o finalizador activo.This method terminates the process without running any active try
/finally
blocks or finalizers.
El Environment.FailFast
método escribe la message
cadena en el registro de eventos de aplicación Windows, crea un volcado de memoria de la aplicación y, a continuación, finaliza el proceso actual.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.
La información se envía a Microsoft mediante Informe de errores de Windows.Information is reported to Microsoft by using Windows Error Reporting. Para obtener más información, vea Informe de errores de Windows: Introducción.For more information, see Windows Error Reporting: Getting Started. Los informes de errores de Microsoft incluyen message
e exception
información, que proporciona los detalles que se usan para clasificar el error.Error reporting to Microsoft includes message
and exception
information, which provides details used to classify the error. Aunque exception
no se controla porque se termina el proceso, todavía se obtiene la información contextual que provocó la excepción.Although exception
is not handled because the process is terminated, the contextual information that raised the exception is still obtained.
Si exception
es null
, o si exception
no se produce, este método funciona igual que la FailFast(String) sobrecarga del método.If exception
is null
, or if exception
is not thrown, this method operates the same as the FailFast(String) method overload.
Utilice el Environment.FailFast
método en lugar del Exit método para finalizar la aplicación si el estado de la aplicación está dañado más allá de la reparación y la ejecución de los try
/ finally
bloques y finalizadores de la aplicación dañará los recursos del programa.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.
Al llamar al Environment.FailFast
método para finalizar la ejecución de una aplicación que se ejecuta en el depurador de Visual Studio, se produce una excepción ExecutionEngineException y se desencadena automáticamente el Asistente para la depuración administrada (MDA) fatalexecutionerror.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).