ApplicationContext.ExitThread メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ApplicationContext.ExitThread メソッドの意味・解説 

ApplicationContext.ExitThread メソッド

スレッドのメッセージ ループを終了します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As ApplicationContext

instance.ExitThread
public void ExitThread ()
public:
void ExitThread ()
public void ExitThread ()
解説解説

このメソッドは ExitThreadCore を呼び出します。

メモメモ

実際にスレッドを終了するのは、ExitThread や ExitThreadCore ではありません。これらのメソッドは、Application オブジェクトが待機する ThreadExit イベントを発生させます。それを受けて、Application オブジェクトがスレッドを終了させます。

使用例使用例

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();
    }
}
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();
   }
}


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();
    }
} //OnFormClosed
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

ApplicationContext.ExitThread メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ApplicationContext.ExitThread メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS