共用方式為


ServiceController.CanPauseAndContinue 屬性

定義

取得值,表示服務是否可以暫停和繼續。

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

屬性值

如果服務可以暫停,則為 true,否則為 false

屬性

例外狀況

存取系統 API 時發生的錯誤。

找不到服務。

範例

下列範例示範如何使用 CanPauseAndContinue 屬性來判斷服務是否可以暫停並繼續。 此範例是針對 類別提供的較大範例的 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())

適用於