SystemEvents.SessionEnded 事件

定義

當使用者正在登出或正在關閉系統時發生。Occurs when the user is logging off or shutting down the system.

public:
 static event Microsoft::Win32::SessionEndedEventHandler ^ SessionEnded;
public static event Microsoft.Win32.SessionEndedEventHandler SessionEnded;
public static event Microsoft.Win32.SessionEndedEventHandler? SessionEnded;
member this.SessionEnded : Microsoft.Win32.SessionEndedEventHandler 
Public Shared Custom Event SessionEnded As SessionEndedEventHandler 

事件類型

SessionEndedEventHandler

例外狀況

目前內容不支援系統事件告知。System event notifications are not supported under the current context. 例如,伺服器處理序可能就不支援全域系統事件告知。Server processes, for example, might not support global system event notifications.

建立系統事件視窗執行緒的嘗試未成功。The attempt to create a system events window thread did not succeed.

備註

注意

只有在訊息泵正在執行時,才會引發此事件。This event is only raised if the message pump is running. 在 Windows 服務中,除非使用隱藏的表單,或手動啟動了訊息泵,否則不會引發此事件。In a Windows service, unless a hidden form is used or the message pump has been started manually, this event will not be raised. 如需示範如何在 Windows 服務中使用隱藏的表單來處理系統事件的程式碼範例,請參閱 SystemEvents 類別。For a code example that shows how to handle system events by using a hidden form in a Windows service, see the SystemEvents class.

警告

因為這是靜態事件,所以您必須在應用程式處置時中斷連結事件處理常式,否則會導致記憶體流失。Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result.

適用於

另請參閱