IBackgroundTaskInstance.Canceled Event

Definition

Attaches a cancellation event handler to the background task instance.

For Windows Phone 8.x app, if the device becomes low on memory, background tasks may be terminated without any warning and without raising the OnCanceled event. This helps to ensure the user experience of the app in the foreground. Your background task should be designed to handle this scenario. Note that this only applies to Windows Phone.

public:
 event BackgroundTaskCanceledEventHandler ^ Canceled;
// Register
event_token Canceled(BackgroundTaskCanceledEventHandler const& handler) const;

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

// Revoke with event_revoker
IBackgroundTaskInstance::Canceled_revoker Canceled(auto_revoke_t, BackgroundTaskCanceledEventHandler const& handler) const;
event BackgroundTaskCanceledEventHandler Canceled;
function onCanceled(eventArgs) { /* Your code */ }
iBackgroundTaskInstance.addEventListener("canceled", onCanceled);
iBackgroundTaskInstance.removeEventListener("canceled", onCanceled);
- or -
iBackgroundTaskInstance.oncanceled = onCanceled;
Event Canceled As BackgroundTaskCanceledEventHandler 

Event Type

Applies to