I cancel my operation by calling the CancelAsync()
method on the BackgroundWorker, and when execution falls into the event RunWorkerCompleted
, property Cancelled
on RunWorkerCompletedEventArgs
is false.
Though, I couldn't quite figure out when or where I should set it to true
, as found in the EventArgs
property. So, how?
From MSDN:
The Cancelled property of RunWorkerCompletedEventArgs indicates whether a cancellation request was processed by the background operation.
If your code in the DoWork event handler detects a cancellation request by checking the CancellationPending flag and setting the Cancel flag of DoWorkEventArgs to true, the Cancelled flag of RunWorkerCompletedEventArgs also will be set to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With