ServiceBase.CanHandlePowerEvent 属性

定义

获取或设置一个值,该值指示服务是否可以处理计算机电源状态更改通知。Gets or sets a value indicating whether the service can handle notifications of computer power status changes.

public:
 property bool CanHandlePowerEvent { bool get(); void set(bool value); };
public bool CanHandlePowerEvent { get; set; }
member this.CanHandlePowerEvent : bool with get, set
Public Property CanHandlePowerEvent As Boolean

属性值

Boolean

如果服务处理 PowerBroadcastStatus 类中指示的计算机电源状态更改,则为 true;否则为 falsetrue if the service handles the computer power status changes indicated in the PowerBroadcastStatus class, otherwise, false.

例外

此属性将在服务启动后被修改。This property is modified after the service was started.

注解

当计算机电源状态更改时,服务控制管理器 (SCM) 使用的值验证服务是否接受电源事件命令 CanHandlePowerEventWhen the computer power status changes, the Service Control Manager (SCM) verifies whether the service accepts power event commands using the value of CanHandlePowerEvent.

如果 CanHandlePowerEventtrue ,则将该命令传递到服务,并在 OnPowerEvent 定义时调用方法。If CanHandlePowerEvent is true, the command is passed to the service and the OnPowerEvent method is called if defined. 如果 OnPowerEvent 未在派生类中实现,则 SCM 通过空基类方法处理电源事件 ServiceBase.OnPowerEventIf OnPowerEvent is not implemented in the derived class, the SCM handles the power event through the empty base class ServiceBase.OnPowerEvent method.

适用于

另请参阅