暂停后恢复backgroundWorker [英] Resume backgroundWorker after pause

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

问题描述


i是这个.Net世界的新手所以我面临这么多问题就是其中之一,我想在暂停之后恢复我的backgroundWorker所以我该怎么做(在Windows窗体中)请帮我。



先谢谢..

Hi i am newbie of this .Net world so i am facing so many problem here is one of them,I want to resume my backgroundWorker after made it pause so how can i do it(In Windows Form) please help me.

Thanks in Advance..

推荐答案

使用WaitHandles实现暂停/恢复操作,例如ManualResetEvent:



Pause / Resume operations are realized with WaitHandles, e.g. the ManualResetEvent:

ManualResetEvent continueEvent = new ManualResetEvent(true);

continueEvent.WaitOne(); //This should call the background thread every then and now

continueEvent.Reset(); //If this is called within an other thread, the thread will pause on continueEvent.WaitOne()

//until
continueEvent.Set() // is called





Source [ ^ ],但请在下次自己google)



(Source[^], but please google yourself the next time)


如果你需要一个有效的演示应用程序,你可以找到它此处。代码可以从 GitHub 下载
If you need a working demo application you can find it here. The code can be downloaded from GitHub


这篇关于暂停后恢复backgroundWorker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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