BackgroundWorker的问题 [英] Problem with BackgroundWorker

查看:84
本文介绍了BackgroundWorker的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我取消BackgroundWorker时,整个GUI都崩溃了.

Sometimes when I''m Cancelling my BackgroundWorker, the whole GUI collapses. Any ideas why it could happen?

推荐答案

尝试添加以下行:
Try adding the following line :
handler.WorkerReportsProgress = true;






and

BackgroundWorker worker = (BackgroundWorker) sender;
while(!worker.CancellationPending)
{
    // Dequeue from queue... and do some stuff

...

    // all done
    worker.ReportProgress(100);
}
e.Cancel = true;


这篇关于BackgroundWorker的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆