Application.EnteredBackground 事件

定義

當應用程式從前景移至背景時發生。

public:
 virtual event EnteredBackgroundEventHandler ^ EnteredBackground;
// Register
event_token EnteredBackground(EnteredBackgroundEventHandler const& handler) const;

// Revoke with event_token
void EnteredBackground(event_token const* cookie) const;

// Revoke with event_revoker
Application::EnteredBackground_revoker EnteredBackground(auto_revoke_t, EnteredBackgroundEventHandler const& handler) const;
public event EnteredBackgroundEventHandler EnteredBackground;
function onEnteredBackground(eventArgs) { /* Your code */ }
application.addEventListener("enteredbackground", onEnteredBackground);
application.removeEventListener("enteredbackground", onEnteredBackground);
- or -
application.onenteredbackground = onEnteredBackground;
Public Custom Event EnteredBackground As EnteredBackgroundEventHandler 

事件類型

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

當使用者離開應用程式時,就會引發此事件。 此事件的事件處理常式可以執行的時間有限。

當您的 App 移至背景時,系統所強制執行的記憶體限制可能會變更。 使用此事件來檢查目前的記憶體耗用量和釋放資源,以保持低於限制,讓您的 app 不會暫停,而且可能在背景中終止。 如需詳細資訊 ,請參閱當您的應用程式移至背景時釋放記憶體

EnteredBackground 事件會在註冊所在的 Apartment 中執行。

適用於

另請參閱