WebUIApplication.BackgroundActivated WebUIApplication.BackgroundActivated WebUIApplication.BackgroundActivated WebUIApplication.BackgroundActivated WebUIApplication.BackgroundActivated Event


Invoked when the application is activated in the background.

public : event BackgroundActivatedEventHandler BackgroundActivated
// Register
event_token BackgroundActivated(BackgroundActivatedEventHandler const& handler) const;

// Revoke with event_token
void BackgroundActivated(event_token const& cookie) const;

// Revoke with event_revoker
BackgroundActivated_revoker BackgroundActivated(auto_revoke_t, BackgroundActivatedEventHandler const& handler) const;
public event BackgroundActivatedEventHandler BackgroundActivated
Public Event BackgroundActivated As BackgroundActivatedEventHandler
function onBackgroundActivated(eventArgs){/* Your code */}

webuiApplication.addEventListener("backgroundactivated", onBackgroundActivated);
webuiApplication.removeEventListener("backgroundactivated", onBackgroundActivated);


BackgroundActivated is a special UWP background task that runs as a handler on the view thread (or background script, see below). Unlike a regular background task running on a worker thread, this provides access to the DOM and referenece to foreground views.

This event is the web app equivalent of the Windows.UI.Xaml Application.OnBackgroundActivated event. In the web app case specifically, if there is no running view thread (the app is not running), the event will activate the app's background script and fire there.

Similar to XAML, to denote a background script as background activation, a null taskEntryPoint is provided to BackgroundTaskBuilder. This background task is registered programmatically (rather than declared in the appxmanifest):

let builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder();
builder.name = 'WwaHostBGActivated';
builder.setTrigger(new background.SystemTrigger(background.SystemTriggerType.timeZoneChange, false));
let backgroundTaskRegistration = builder.register();