ServiceBase.ExitCode プロパティ
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)

Dim instance As ServiceBase Dim value As Integer value = instance.ExitCode instance.ExitCode = 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" ); } }


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


Weblioに収録されているすべての辞書からServiceBase.ExitCode プロパティを検索する場合は、下記のリンクをクリックしてください。

- ServiceBase.ExitCode プロパティのページへのリンク