Suppose I have created multiple threads.
Now I am waiting for multiple object as well using :
WaitOnMultipleObject(...);
Now if I want to know the status of all the thread’s return code. How to do that ?
Do I need to loop for all the thread’s handle in the loop.
GetExitCodeThread(
__in HANDLE hThread,
__out LPDWORD lpExitCode
);
And now check lpExitCode for success / failure code ?
Cheers,
Siddhartha
If you want to wait for a thread to exit, just wait on the thread’s handle. Once the wait completes you can get the exit code for that thread.
This example can be extended to waiting for completion of several thread by passing an array of thread handles to
WaitForMultipleObjects(). Figure out which thread completed using the appropriate offset fromWAIT_OBJECT_0on the return fromWaitForMultipleObjects(), and remove that thread handle from the handle array passed toWaitForMultipleObjects()when calling it to wait for the next thread completion.