首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

backgroundWorker这样写CPU暴高,求解决方法

2011-12-18 
backgroundWorker这样写CPU暴高,求解决办法.我看了以下这篇“如何:在后台下载文件”http://msdn2.microsoft.

backgroundWorker这样写CPU暴高,求解决办法.
我看了以下这篇   “如何:在后台下载文件”
http://msdn2.microsoft.com/zh-cn/library/ms229675(VS.80).aspx


用了之后发现这个问题。
while   (this.backgroundWorker1.IsBusy)
{
    //   Keep   UI   messages   moving,   so   the   form   remains  
    //   responsive   during   the   asynchronous   operation.
    Application.DoEvents();
}


这样等待backgroundWorker1后台运行结束。前台界面是会不卡了。但CPU却非常的高,请教有什么办法解决CPU的问题。

[解决办法]
在 Application.DoEvents();后加一句:Thread.Sleep(1000);

热点排行