Wednesday, 31 March 2010

Waiting for Thread / Process termination

When launching child processes from applications I used to use GetExitCodeProcess on the process handle, checking if STILL_ACTIVE is returned if it is still running.. heres the smart way!

After spawning a process or creating a worker thread the end of the process/thread can be waited on using WaitForSingleObject.

For instance for threads:

HANDLE hThread;
hThread = CreateThread(NULL,0,StartThread,&threadParam,0,NULL);
if(hThread1 != NULL)

For processes:

if (CreateProcess (parameters, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, &pi))

1 comment:

Anonymous said...

What's Up everybody, prime chat board I find It incredibly helpful & it has helped me out so much
I hope to be able to contribute and help others like this forum has helped me

[URL=][B]mcitp enterprise[/B][/URL]