CoreApplication.EnteredBackground 事件

定義

當應用程式進入背景狀態執行時引發。

// Register
static event_token EnteredBackground(EventHandler<EnteredBackgroundEventArgs> const& handler) const;

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

// Revoke with event_revoker
static CoreApplication::EnteredBackground_revoker EnteredBackground(auto_revoke_t, EventHandler<EnteredBackgroundEventArgs> const& handler) const;
public static event System.EventHandler<EnteredBackgroundEventArgs> EnteredBackground;
function onEnteredBackground(eventArgs) { /* Your code */ }
Windows.ApplicationModel.Core.CoreApplication.addEventListener("enteredbackground", onEnteredBackground);
Windows.ApplicationModel.Core.CoreApplication.removeEventListener("enteredbackground", onEnteredBackground);
- or -
Windows.ApplicationModel.Core.CoreApplication.onenteredbackground = onEnteredBackground;
Public Shared Custom Event EnteredBackground As EventHandler(Of EnteredBackgroundEventArgs) 

事件類型

Windows 需求

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

備註

當應用程式不再顯示在前景時,就會引發此事件。

先前,暫停回呼是在使用者完成應用程式會話之後儲存狀態的最佳位置。 不過,現在應用程式可能會繼續在背景中執行,然後因為觸發活動而返回前景,而不會到達暫停的狀態。 在使用者會話位於您輸入的背景事件處理常式之後,儲存資料的最佳位置。

當應用程式移至背景時,記憶體限制也會變更。 最好檢查 MemoryManager 並視需要釋放記憶體,以確保您的應用程式不會終止。

適用於

另請參閱