ApplicationContext.ExitThread メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)



ApplicationContext クラスの概要から抜粋したコード例を次に示します。この例では、開かれたフォームの記録を取り、すべてのフォームが閉じられたときに現在のスレッドを終了します。OnFormClosed メソッドは、Closed イベントのイベント ハンドラです。開かれたフォームの数が 0 になると、ExitThread メソッドを呼び出すことによって現在のスレッドが終了されます。フォームの数は、フォームが表示されたときには formCount 変数の値を 1 つ増やし、フォームが閉じられたときには 1 つ減らすことによって追跡されます。
簡略にするため、コードの一部は示されていません。コード全体については、ApplicationContext を参照してください。
Private Sub OnFormClosed(ByVal sender As Object, ByVal e As EventArgs) ' When a form is closed, decrement the count of open forms. ' When the count gets to 0, exit the app by calling ' ExitThread(). formCount = formCount - 1 If (formCount = 0) Then ExitThread() End If End Sub
private void OnFormClosed(object sender, EventArgs e) { // When a form is closed, decrement the count of open forms. // When the count gets to 0, exit the app by calling // ExitThread(). formCount--; if (formCount == 0) { ExitThread(); } }

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


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

- ApplicationContext.ExitThread メソッドのページへのリンク