February 14, 2014
Called by the operating system to alert a background agent that it is going to be put into a dormant state or terminated.
Assembly: Microsoft.Phone (in Microsoft.Phone.dll)
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.
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.