Environment.FailFast メソッド
アセンブリ: mscorlib (mscorlib.dll 内)


FailFast メソッドは、message パラメータを使用して、ログ エントリを Windows アプリケーションのイベント ログに書き込み、アプリケーションのダンプを作成してから、現在のプロセスを終了させます。
アプリケーションの状態が回復できないほど悪化し、try-finally ブロックやファイナライザでは、プログラム リソースまでダメージを受けてしまうような場合は、Exit メソッドではなく、FailFast メソッドを使用してアプリケーションを終了してください。FailFast メソッドは、現在のプロセスを終了し、すべての CriticalFinalizerObject オブジェクトを実行します。ただし、アクティブな try-finally ブロックまたはファイナライザは一切実行されません。

ログ エントリを Windows アプリケーションのイベント ログに書き込み、現在のプロセスを終了させるコード例を次に示します。
' This code example demonstrates the Environment.FailFast() ' method. Imports System Class Sample Public Shared Sub Main() Dim causeOfFailure As String = "A castrophic failure has occured." ' 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 'Main End Class 'Sample ' 'This code example produces the following results: ' '(No output is produced 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.) '
// This code example demonstrates the Environment.FailFast() // method. using System; class Sample { public static void Main() { string causeOfFailure = "A castrophic failure has occured."; // 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."); } } } /* This code example produces the following results: (No output is produced 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.) */

- SecurityPermission (アンマネージ コードを呼び出すために必要なアクセス許可)。要求値 : LinkDemand; アクセス許可値 : UnmanagedCode

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からEnvironment.FailFast メソッドを検索する場合は、下記のリンクをクリックしてください。

- Environment.FailFast メソッドのページへのリンク