Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

thread ending: how does another thread know??? 2

Status
Not open for further replies.

scienzia

Programmer
Feb 21, 2002
160
IT
How do I know when a thread is ended?!?

I create a thread with beginthread function, and manage to ensure it is closing before closing the program:

readytoclose=TRUE;
endthread();

and everithing is ok, but if I press CTRL_ALT_CANC I see the program is still alive, and I know the objects haven't been closed...

How can I solve this problem...
 
Try with Functions GetThreadPriority( hThread) (returns THREAD_PRIORITY_ERROR_RETURN if thread does not exist), GetThreadTimes(hThread,...) (returns 0 if thread does not exist) ResumeThread(hThread) etc.
 
I think the best way is GetExitCodeThread:

DWORD dwExitCode;
if ( !GetExitCodeThread ( hThread, &dwExitCode ))
{ // something went wrong, probably hThread invalid
..... } else
{ if ( dwExitCode == STILL_ACTIVE )
{ // Thread is still running
.... } else
{ // Thread has stopped
.... } }
Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top