ServiceController.CanStop プロパティ

定義

サービスをいったん開始してから停止できるかどうかを示す値を取得します。

public:
 property bool CanStop { bool get(); };
public bool CanStop { get; }
[System.ServiceProcess.ServiceProcessDescription("SPCanStop")]
public bool CanStop { get; }
member this.CanStop : bool
[<System.ServiceProcess.ServiceProcessDescription("SPCanStop")>]
member this.CanStop : bool
Public ReadOnly Property CanStop As Boolean

プロパティ値

Boolean

サービスを停止でき、OnStop() メソッドを呼び出すことができる場合は true。それ以外の場合は false

属性

例外

システム API にアクセス中にエラーが発生しました。

サービスが見つかりませんでした。

次の例では、このプロパティを使用して、 CanStop サービスが停止イベントのハンドラーを提供するかどうかを判断します。 この例は、クラスに提供されるより大きな例の ServiceController 一部です。

// Display properties for the Simple Service sample
// from the ServiceBase example.
ServiceController sc = new ServiceController("Simple Service");
Console.WriteLine("Status = " + sc.Status);
Console.WriteLine("Can Pause and Continue = " + sc.CanPauseAndContinue);
Console.WriteLine("Can ShutDown = " + sc.CanShutdown);
Console.WriteLine("Can Stop = " + sc.CanStop);
' Display properties for the Simple Service sample 
' from the ServiceBase example
Dim sc As New ServiceController("Simple Service")
Console.WriteLine("Status = " + sc.Status.ToString())
Console.WriteLine("Can Pause and Continue = " + _
    sc.CanPauseAndContinue.ToString())
Console.WriteLine("Can ShutDown = " + sc.CanShutdown.ToString())
Console.WriteLine("Can Stop = " + sc.CanStop.ToString())

適用対象