Click to See Complete Forum and Search --> : how to use GetExitCodeThread()
VCProgrammer
May 19th, 2007, 03:21 AM
Hi all,
Can anybody plz tell me how to use GetExitCodeThread Function.
my thread object is CloseTh.I am not getting how to pass second parameter.
<pre>
DWORD lpExitCode;
GetExitCodeThread(CloseTh->m_hThread,lpExitCode);
</pre>
when i write this,this error is coming
cannot convert parameter 2 from 'unsigned long' to 'unsigned long *'
thanks in advance
golanshahar
May 19th, 2007, 03:25 AM
Like this:
DWORD lpExitCode;
::GetExitCodeThread(CloseTh->m_hThread,&lpExitCode);
Cheers
VCProgrammer
May 19th, 2007, 03:34 AM
thanku its working but now i want to knw that how to reterieve lpExitCode value.
like its giving &lpExitCode = 0x0012F330 &
lpExitCode = 3425973836;
i have used TerminateThread Function like this
[code]
::TerminateThread(CloseTh->m_hThread,0);
[\code]
now by theses values how can i find that my thread is closed or not.
laitinen
May 19th, 2007, 04:29 AM
DWORD lpExitCode;
::GetExitCodeThread(CloseTh->m_hThread, &lpExitCode);
if(STILL_ACTIVE == lpExitCode)
//Thread is still active
else
//Thread has died.
However, note that STILL_ACTIVE is equal to -1, and if you by a mistake returns -1 from your thread to indicate an error in the thread then you will think that the thread is still running. Of course one should not return -1 to indicate error in thread.
But to avoid this you can use WaitForSingleObject instead:
if(WaitForSingleObject(CloseTh->m_hThread, 0) == WAIT_OBJECT_0)
{
// The thread has finished!!!
}
Laitinen
Marc G
May 19th, 2007, 01:14 PM
[ moved thread ]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.