ServiceBase.CanHandlePowerEvent Property

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

Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)

public bool CanHandlePowerEvent { get; set; }
/** @property */
public boolean get_CanHandlePowerEvent ()

/** @property */
public void set_CanHandlePowerEvent (boolean value)

public function get CanHandlePowerEvent () : boolean

public function set CanHandlePowerEvent (value : boolean)

Not applicable.

Property Value

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

Exception typeCondition


This property is modified after the service was started.

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.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0