gpt4 book ai didi

c# - BackgroundWorker RunWorkerCompletedEventArgs.Cancelled 始终为 false

转载 作者:可可西里 更新时间:2023-11-01 08:07:41 26 4
gpt4 key购买 nike

我通过调用 BackgroundWorker 上的 CancelAsync() 方法取消我的操作,当执行落入事件 RunWorkerCompleted 时,属性 Cancelled RunWorkerCompletedEventArgs 为假。

不过,我不太清楚应该在何时何地将其设置为 true,如 EventArgs 属性中所示。那么,如何呢?

最佳答案

来自 MSDN :

The Cancelled property ofRunWorkerCompletedEventArgsindicates whether a cancellationrequest was processed by thebackground operation.

If your code inthe DoWork event handler detects acancellation request by checking theCancellationPending flag and settingthe Cancel flag ofDoWorkEventArgsto true, the Cancelled flag ofRunWorkerCompletedEventArgsalso will be set to true.

关于c# - BackgroundWorker RunWorkerCompletedEventArgs.Cancelled 始终为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4758505/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com