简体   繁体   English

VS2010中的BackgroundWorker不在其他线程中运行

[英]BackgroundWorker in VS2010 doesn't run in another thread

I created a WinForm in Visual Studio 2010 (c++), almost the same as this example: http://msdn.microsoft.com/en-us/library/waw3xexc.aspx 我在Visual Studio 2010(c ++)中创建了一个WinForm,几乎与此示例相同: http : //msdn.microsoft.com/zh-cn/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. 但是,当我单击“插入” BackgroundWorker的按钮时,它“粘住”了WinForm,因此我无法移动它或在函数运行时单击“停止按钮”。

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. 似乎BackgroundWorker与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. BackgroundWorker实际上在另一个线程上运行,但是它发送更新进度的事件过于频繁,并且那些事件在主窗体中“午餐”功能(更新ProgressBar),并且此函数“阻塞”了窗体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Boost.Locale示例不在VS2010中运行 - Boost.Locale Examples doesn't runs in VS2010 Boost示例无法在VS2010上编译? - Boost example doesn't compile on VS2010? 在VS2010项目中更改输出目录不起作用 - Changing output directory in VS2010 project doesn't work C ++如何等待在另一个线程上执行的方法然后主线程完成(VS2010) - C++ how to wait for a method that gets executed on another thread then the main thread to finish (VS2010) 导入DLL的工作原理不同(VS2003至VS2010,多线程至多线程DLL) - Importing DLL's doesn't work the same (VS2003 to VS2010, multithreaded to multithreaded DLL) VS2010 / Intel Fortran找不到多义定义的符号 - VS2010/Intel Fortran doesn't find mulitiply defined symbols CRXIR2不适用于Windows 7上的VS2010,也不适用于Vista - CRXIR2 doesn't work with VS2010 on Windows 7 nor on Vista 卸载程序不会在VS2010安装程序项目中将复制的库删除到“系统文件夹”。 - Uninstaller doesn't delete copied library to System Folder in VS2010 installer project. <hash_set>等于运算符在VS2010中不起作用 - <hash_set> equality operator doesn't work in VS2010 VS2010 C ++ F7不在“调试”中创建可执行文件 - VS2010 C++ F7 doesn't create executable in 'debug'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM