Delen via


CoreApplication.LeavingBackground Event

Definition

Fired just before application UI becomes visible.

// Register
static event_token LeavingBackground(EventHandler<LeavingBackgroundEventArgs> const& handler) const;

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

// Revoke with event_revoker
static CoreApplication::LeavingBackground_revoker LeavingBackground(auto_revoke_t, EventHandler<LeavingBackgroundEventArgs> const& handler) const;
public static event System.EventHandler<LeavingBackgroundEventArgs> LeavingBackground;
function onLeavingBackground(eventArgs) { /* Your code */ }
Windows.ApplicationModel.Core.CoreApplication.addEventListener("leavingbackground", onLeavingBackground);
Windows.ApplicationModel.Core.CoreApplication.removeEventListener("leavingbackground", onLeavingBackground);
- or -
Windows.ApplicationModel.Core.CoreApplication.onleavingbackground = onLeavingBackground;
Public Shared Custom Event LeavingBackground As EventHandler(Of LeavingBackgroundEventArgs) 

Event Type

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Remarks

Previously the best location to load UI was in your activated or resuming event handler. Now your handler for the LeavingBackground event is the best place to do your final checks to ensure that the UI is ready for presentation. It is important to check that visual assets are ready by this time because this is the last opportunity to do work before your application is visible to the user.

Applies to

See also