This documentation is archived and is not being maintained.

ServiceBase.CanHandlePowerEvent Property

Gets or sets a value indicating whether the service can handle notifications of computer power status changes.

[Visual Basic]
Public Property CanHandlePowerEvent As Boolean
[C#]
public bool CanHandlePowerEvent {get; set;}
[C++]
public: __property bool get_CanHandlePowerEvent();
public: __property void set_CanHandlePowerEvent(bool);
[JScript]
public function get CanHandlePowerEvent() : Boolean;
public function set CanHandlePowerEvent(Boolean);

Property Value

true if the service handles the computer power status changes indicated in the PowerBroadcastStatus class, otherwise, false.

Exceptions

Exception Type Condition
InvalidOperationException This property is modified after the service was started.

Remarks

When the computer power status changes, the Service Control Manager (SCM) verifies whether the service accepts power event commands using the value of CanHandlePowerEvent.

If CanHandlePowerEvent is true, the command is passed to the service and the OnPowerEvent method is called if defined. If OnPowerEvent is not implemented in the derived class, the SCM handles the power event through the empty base class ServiceBase.OnPowerEvent method.

Requirements

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

ServiceBase Class | ServiceBase Members | System.ServiceProcess Namespace | PowerBroadcastStatus | OnPowerEvent | CanPauseAndContinue | CanShutdown | CanStop

Show: