OnCancel Method
Collapse the table of content
Expand the table of content

BackgroundAgent.OnCancel Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Called by the operating system to alert a background agent that it is going to be put into a dormant state or terminated.

Namespace:  Microsoft.Phone
Assembly:  Microsoft.Phone (in Microsoft.Phone.dll)

protected internal virtual void OnCancel()

The OnCancel method is called by the operating system on a background thread. When this method is called, a background agent should clean up its resources, prepare to be terminated, and then call NotifyComplete() or Abort() to alert the operating system that processing is complete. Agents have a maximum of five seconds to complete this task. If an agent takes longer than five seconds, it is terminated immediately along with any other agents hosted in the same process.

Caution noteCaution:

OnCancel is not called for ScheduledTaskAgent. Periodic and resource-intensive agents should expect that they can be terminated at any time and should be designed to recover from being terminated without notification.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Show:
© 2016 Microsoft