简单来说:
我通过调用BackgroundWorker上的CancelAsync()方法取消我的操作,并且当执行落在事件RunWorkerCompleted中时,RunWorkerCompletedEventArgs上的“取消”属性为false.我无法弄清楚我应该将其设置为true,因为这是一个EventArgs属性.
任何人都可以给我一些帮助吗?
另外,对不起,如果它是一个重复的,但我找不到任何有关的问题.
解决方法
从
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.