Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading visualc&x2B+;函数没有看到线程终止_Multithreading_Visual Studio 2010_Visual C++ - Fatal编程技术网

Multithreading visualc&x2B+;函数没有看到线程终止

Multithreading visualc&x2B+;函数没有看到线程终止,multithreading,visual-studio-2010,visual-c++,Multithreading,Visual Studio 2010,Visual C++,我的表单的onClick事件函数中有以下代码: HANDLE hThread; unsigned threadID; output->Text = "Starting"; _beginthreadex( NULL, 0, &start, NULL, 0, &threadID ); DWORD dwRes = WaitForSingleObject( hThread, INFINITE ); if (dwRes == WAIT_OBJECT_0 || dwRes == W

我的表单的onClick事件函数中有以下代码:

HANDLE hThread;
unsigned threadID;

output->Text = "Starting";
_beginthreadex( NULL, 0, &start, NULL, 0, &threadID );
DWORD dwRes = WaitForSingleObject( hThread, INFINITE );

if (dwRes == WAIT_OBJECT_0 || dwRes == WAIT_ABANDONED || dwRes == WAIT_TIMEOUT){
CloseHandle( hThread );
output->Text = "Done";
}
函数
start
返回
0
无论发生什么情况。我看到
output
标签更改为“start”,但它从未更改为“Done”。但是,我在Visual Studio输出窗口中看到以下消息:

The thread 'Win32 Thread' (0x2dc) has exited with code 0 (0x0).
The thread '<No Name>' (0x2dc) has exited with code 0 (0x0).
线程“Win32线程”(0x2dc)已退出,代码为0(0x0)。
线程“”(0x2dc)已退出,代码为0(0x0)。

我不知道为什么
if
语句没有捕捉到线程的末尾。是否有任何函数可以与线程句柄一起使用来探测线程的状态

您尚未将线程句柄分配给hThread

应该是:

hThread = _beginthreadex( NULL, 0, &start, NULL, 0, &threadID );