This topic has not yet been rated - Rate this topic

BackgroundAgent.OnCancel Method

May 02, 2013

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.0, 7.1

Windows Phone

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.