當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C# Environment FailFast()用法及代碼示例

在這裏,我們將了解 Environment 類的 FailFast() 方法。此方法用於在寫入 Windows 應用程序事件日誌後立即終止進程。

用法:

void Environment.FailFast(string eventLog);

參數:

  • eventLog: 將記錄在 Windows 應用程序事件日誌中的消息。

返回值:

此方法不返回任何值。

程序:

下麵給出了演示使用 Environment 類的 FailFast() 方法的源代碼。給定的程序已成功編譯並執行。

using System;

class Sample
{
    //Entry point of Program
    static public void Main()
    {
        Console.WriteLine("Program before termination of process");
     
        Environment.FailFast("Terminate program by Me");
        
        Console.WriteLine("Program after termination of process");
    }
}

輸出:

Program before termination of process
Press any key to continue . . .



相關用法


注:本文由純淨天空篩選整理自 C# program to demonstrate the use of FailFast() method of Environment class。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。