ServiceController.CanPauseAndContinue 属性     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示是否可以暂停和继续服务。
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 : boolPublic 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())