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

适用于