CoreApplication.EnteredBackground Event
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Fired when the app enters the running in the background state.
// 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)
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
This event is fired when your app is no longer visible in the foreground.
Previously your suspending callback was the best place to save state after a user finished a session with your app. However, now an application may continue running in the background and then move back to the foreground due to trigger activity without ever reaching the suspended state. The best place to save data after a user session is in your entered background event handler.
Memory limits also change as an app moves into the background. It is best to check the MemoryManager and release memory if needed to ensure your app does not get terminated.
Product | Versions |
---|---|
WinRT | Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |