I have created a thread as follows,
DWORD Id;
CreateThread(0, 0, think, pcon, 0, &Id);
How to check if the thread is running or if it has come out?
Thanks.
This is a discussion on How to check if a thread is running or has come out ? within the Windows Programming forums, part of the Platform Specific Boards category; I have created a thread as follows, DWORD Id; CreateThread(0, 0, think, pcon, 0, &Id); How to check if the ...
I have created a thread as follows,
DWORD Id;
CreateThread(0, 0, think, pcon, 0, &Id);
How to check if the thread is running or if it has come out?
Thanks.
I have the same question, but temporarily I have mine set up like this:
And then if you want to know if the thread is running or not, just use a simple if(thread) statement.Code:bool thread=false; // just using your example DWORD WINAPI think(LPVOID pcon) { thread = true; // do stuff here thread = false; return whatever; } whatever whatever(whatever) { DWORD Id; CreateThread(0, 0, think, pcon, 0, &Id); }
Save the return value of the CreateThread function.
Use this handle in the WaitForSingleObject function with timeout=0 (or not zero if you want to wait for thread to exit)
When you know where the state of the handle is signaled or not.
The handle is signaled on exit of the thread.
If I have eight hours for cutting wood, I spend six sharpening my axe.