加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – BackgroundWorker RunWorkerCompletedEventArgs.Cancelled

发布时间:2020-12-15 04:06:36 所属栏目:百科 来源:网络整理
导读:简单来说: 我通过调用BackgroundWorker上的CancelAsync()方法取消我的操作,并且当执行落在事件RunWorkerCompleted中时,RunWorkerCompletedEventArgs上的“取消”属性为false.我无法弄清楚我应该将其设置为true,因为这是一个EventArgs属性. 任何人都可以给我
简单来说:

我通过调用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读