ServiceBase.OnPowerEvent(PowerBroadcastStatus) 方法

定義

在衍生類別中實作時,當電腦的電源狀態已經變更時執行。When implemented in a derived class, executes when the computer's power status has changed. 這適用於攜帶型電腦,當它們進入暫停模式的時候,不同於系統關閉。This applies to laptop computers when they go into suspended mode, which is not the same as a system shutdown.

protected:
 virtual bool OnPowerEvent(System::ServiceProcess::PowerBroadcastStatus powerStatus);
protected virtual bool OnPowerEvent (System.ServiceProcess.PowerBroadcastStatus powerStatus);
abstract member OnPowerEvent : System.ServiceProcess.PowerBroadcastStatus -> bool
override this.OnPowerEvent : System.ServiceProcess.PowerBroadcastStatus -> bool
Protected Overridable Function OnPowerEvent (powerStatus As PowerBroadcastStatus) As Boolean

參數

powerStatus
PowerBroadcastStatus

PowerBroadcastStatus,表示來自系統關於電源狀態的通知。A PowerBroadcastStatus that indicates a notification from the system about its power status.

傳回

當在衍生類別中實作時,您的應用程式之需求會決定將傳回什麼值。When implemented in a derived class, the needs of your application determine what value to return. 例如,如果傳遞 QuerySuspend 廣播狀態,您可能會導致您的應用程式傳回 false 來拒絕查詢。For example, if a QuerySuspend broadcast status is passed, you could cause your application to reject the query by returning false.

備註

OnPowerEvent來指定發生PowerBroadcastStatus列舉中所指出的系統事件時所發生的處理,例如,當電腦處於暫停模式或表示電力偏低時。Use OnPowerEvent to specify the processing that occurs when the system event indicated in the PowerBroadcastStatus enumeration occurs--for example, when the computer is placed in suspended mode or indicates low battery power.

OnPowerEventCanHandlePowerEvent屬性為true時,應該會覆寫。OnPowerEvent is expected to be overridden when the CanHandlePowerEvent property is true.

適用於

另請參閱