ServiceBase.ExitCode プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ServiceBase.ExitCode プロパティの意味・解説 

ServiceBase.ExitCode プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

サービスの終了コード取得または設定します

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

<ComVisibleAttribute(False)> _
Public Property ExitCode As
 Integer
Dim instance As ServiceBase
Dim value As Integer

value = instance.ExitCode

instance.ExitCode = value
[ComVisibleAttribute(false)] 
public int ExitCode { get;
 set; }
[ComVisibleAttribute(false)] 
public:
property int ExitCode {
    int get ();
    void set (int value);
}
/** @property */
public int get_ExitCode ()

/** @property */
public void set_ExitCode (int
 value)

プロパティ
サービスの終了コード

解説解説
使用例使用例

ExitCode プロパティ使用して、ServiceBase から派生したクラスの OnStop メソッド実装正常な終了を示すコード例次に示します。このコード例は、ServiceBase クラストピック取り上げているコード例一部分です。

    ' Stop this service.
    Protected Overrides Sub
 OnStop()
        ' New in .NET Framework version 2.0.
        Me.RequestAdditionalTime(4000)
        ' Signal the worker thread to exit.
        If Not (workerThread Is
 Nothing) AndAlso workerThread.IsAlive Then
#If LOGEVENTS Then
            System.Diagnostics.EventLog.WriteEntry("SimpleService.OnStop",
 DateTime.Now.ToLongTimeString() + _
                " - Stopping the service worker thread.")
#End If
            pause.Reset()
            Thread.Sleep(5000)

            workerThread.Abort()
        End If
        If Not (workerThread Is
 Nothing) Then
#If LOGEVENTS Then
            System.Diagnostics.EventLog.WriteEntry("SimpleService.OnStop",
 DateTime.Now.ToLongTimeString() + _
                " - OnStop Worker thread state = "
 + workerThread.ThreadState.ToString())
#End If
        End If
        ' Indicate a successful exit.
        Me.ExitCode = 0

    End Sub 'OnStop

        // Stop this service.
        protected override void OnStop()
        {
            // New in .NET Framework version 2.0.
            this.RequestAdditionalTime(4000);
            // Signal the worker thread to exit.
            if ((workerThread != null) &&
 (workerThread.IsAlive))
            {
#if LOGEVENTS
                EventLog.WriteEntry("SimpleService.OnStop", DateTime.Now.ToLongTimeString()
 +
                    " - Stopping the service worker thread.");
#endif
                pause.Reset();
                Thread.Sleep(5000);
                workerThread.Abort();

            }
            if (workerThread != null)
            {
#if LOGEVENTS
                EventLog.WriteEntry("SimpleService.OnStop", DateTime.Now.ToLongTimeString()
 +
                    " - OnStop Worker thread state = " +
                    workerThread.ThreadState.ToString());
#endif
            }
            // Indicate a successful exit.
            this.ExitCode = 0;
        }
    // Stop this service.
protected:
    virtual void OnStop() override
    {
        // Signal the worker thread to exit.
        if ( (workerThread != nullptr) && (workerThread->IsAlive)
 )
        {
            Trace::WriteLine( DateTime::Now.ToLongTimeString() + " - Stopping
 the service worker thread.", "OnStop" );
            workerThread->Abort();

            // Wait up to 500 milliseconds for the thread to terminate.
            workerThread->Join( 500 );
        }

        if ( workerThread != nullptr )
        {
            Trace::WriteLine( DateTime::Now.ToLongTimeString() + " - Worker
 thread state = " + workerThread->ThreadState.ToString(), "OnStop"
 );
        }
    }
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からServiceBase.ExitCode プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からServiceBase.ExitCode プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からServiceBase.ExitCode プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ServiceBase.ExitCode プロパティのお隣キーワード
検索ランキング

   

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



ServiceBase.ExitCode プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS