开发者

BackgroundWorker in VS2010 doesn't run in another thread

开发者 https://www.devze.com 2023-03-24 19:36 出处:网络
I created a WinForm in Visual Studio 2010 (c++), almost the same as this example: http://msdn.microsoft.com/en-us/library/waw3xexc.aspx

I created a WinForm in Visual Studio 2010 (c++), almost the same as this example: http://msdn.microsoft.com/en-us/library/waw3xexc.aspx

but when I click on the button that "lunch" the BackgroundWorker it "stucks" the WinForm, so I can't move it or click on "stop button" for the time the function runs.

The function runs as desired - is returns the expected result, and also the progress bar is ok. It seems that the BackgroundWorker runs in the 开发者_开发百科same thread as the WinForm.

What might be the problem?

Thanks!


I found the problem.

The BackgroundWorker actually runs on another thread but it send Events of update progress too often and those events "lunch" function in the main form - that updates ProgressBar - and this funcion "stucks" the form.

0

精彩评论

暂无评论...
验证码 换一张
取 消