Requests cancellation of a pending background operation.
Assembly: System (in System.dll)
The method submits a request to stop the background operation and sets the CancellationPending property to true.
When you call , your background operation will be able to stop and exit. The operation code should periodically check the CancellationPending property to see whether it has been set to true.
Be aware that your code in the DoWork event handler may complete its work as a cancellation request is being made, and your polling loop may miss CancellationPending being set to true. In this case, the Cancelled flag of System.ComponentModel.RunWorkerCompletedEventArgs in your RunWorkerCompleted event handler will not be set to true, even though a cancellation request was made. This situation is called a race condition and is a common concern in multithreaded programming. For more information about multithreading design issues, seeManaged Threading Best Practices.
The following code example demonstrates the use of the method to cancel a background operation. To view the complete code for this sample, see How to use a background worker for Windows Phone 8.