DoWork就是这样:
DoLengthyWork();
//this is never executed
if(bgWorker.CancellationPending)
{
MessageBox.Show("Up to here? ...");
e.Cancel = true;
}
我使用bgWorker.CancelAsync();
触发取消如果无法访问 bgWorker.CancellationPending ,因为它被DoLengthyWork阻止我可以如何停止BackGround Worker?
答案 0 :(得分:0)
您的问题是,DoWork
功能的执行不会达到CancellationPending
条件。事实上,正如balexandre所说,您应该知道组织DoLengthyWork
场景以定期检查CancellationPending
条件。