ServiceController.CanShutdown 属性

定义

获取一个值,该值指示在系统关闭时是否应通知服务。

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

属性值

Boolean

如果系统关闭时应通知服务,则为 true;否则为 false

属性

例外

访问 API 时出错。

未找到服务。

示例

以下示例演示如何使用 CanShutdown 属性来确定服务是否为关闭事件提供处理程序。 此示例是为 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())

适用于