Your event handler DoWorkperiodically checks BackgroundWorker.CancellationPendingand sets DoWorkEventArgs.Cancelto true before returning if it was canceled.
The event handler RunWorkerCompletedmust check the property RunWorkerCompletedEventArgs.Cancelledto determine if the event handler is canceled DoWork(set DoWorkEventArgs.Cancelto true).
, (BackgroundWorker.CancellationPending - true), (RunWorkerCompletedEventArgs.Cancelled - false). , , , , ( ), - , ).
, - , .
- , CancellationPending, , BackgroundWorker, . , , BackgroundWorkers. , .
, DoWorkEventArgs.Cancel, , (, ), , .