G
Guest
Hello,
When closing my multithread application, before stopping the main thread I
wait, in this main thread, for a secondary thread to exit. I use for it the
function WaitForSingleObject which never end.
When debugging I can check that this secondary thread is returning zero and
exiting but by using spy++ I can see that this thread is still existing.
What can prevent this thread to terminate whereas this thread as returned
zero ?
Code sample :
HANDLE hThreadInterrogationPorte;
class CCNR_FonctionsDeBaseCN
{
(...)
static DWORD WINAPI ThreadInterrogationPorte(LPVOID lpParam);
(...)
}
DWORD WINAPI CCNR_FonctionsDeBaseCN::ThreadInterrogationPorte(LPVOID lpParam)
{
(...)
return 0;
}
CCNR_FonctionsDeBaseCN::CCNR_FonctionsDeBaseCN(CString PathOfCurrentDir)
{
(...)
DWORD ThreadId;
m_ParamCycleInterrogationPorte.hThreadInterrogationPorte =
CreateThread(
NULL, //LPSECURITY_ATTRIBUTES
lpThreadAttributes,
0, //SIZE_T dwStackSize,
&ThreadInterrogationPorte, //LPTHREAD_START_ROUTINE lpStartAddress,
&m_ParamCycleInterrogationPorte, //LPVOID lpParameter,
0, //Run immediately DWORD dwCreationFlags,
&ThreadId //LPDWORD lpThreadId
);
(...)
}
CCNR_FonctionsDeBaseCN::~CCNR_FonctionsDeBaseCN()
{
(...)
if(m_ParamCycleInterrogationPorte.hThreadInterrogationPorte != NULL)
WaitForSingleObject(m_ParamCycleInterrogationPorte.hThreadInterrogationPorte,INFINITE);
(...)
}
Best regards
JsCHarly
When closing my multithread application, before stopping the main thread I
wait, in this main thread, for a secondary thread to exit. I use for it the
function WaitForSingleObject which never end.
When debugging I can check that this secondary thread is returning zero and
exiting but by using spy++ I can see that this thread is still existing.
What can prevent this thread to terminate whereas this thread as returned
zero ?
Code sample :
HANDLE hThreadInterrogationPorte;
class CCNR_FonctionsDeBaseCN
{
(...)
static DWORD WINAPI ThreadInterrogationPorte(LPVOID lpParam);
(...)
}
DWORD WINAPI CCNR_FonctionsDeBaseCN::ThreadInterrogationPorte(LPVOID lpParam)
{
(...)
return 0;
}
CCNR_FonctionsDeBaseCN::CCNR_FonctionsDeBaseCN(CString PathOfCurrentDir)
{
(...)
DWORD ThreadId;
m_ParamCycleInterrogationPorte.hThreadInterrogationPorte =
CreateThread(
NULL, //LPSECURITY_ATTRIBUTES
lpThreadAttributes,
0, //SIZE_T dwStackSize,
&ThreadInterrogationPorte, //LPTHREAD_START_ROUTINE lpStartAddress,
&m_ParamCycleInterrogationPorte, //LPVOID lpParameter,
0, //Run immediately DWORD dwCreationFlags,
&ThreadId //LPDWORD lpThreadId
);
(...)
}
CCNR_FonctionsDeBaseCN::~CCNR_FonctionsDeBaseCN()
{
(...)
if(m_ParamCycleInterrogationPorte.hThreadInterrogationPorte != NULL)
WaitForSingleObject(m_ParamCycleInterrogationPorte.hThreadInterrogationPorte,INFINITE);
(...)
}
Best regards
JsCHarly