question with Thread Termination
crucial: Is this a ok way to terminate a thread?.
Code:
CWinThread *pThread=NULL;
UINT MyThread(LPVOID MyParam)
{
while(1)
{
If(IsTrue)
{
//Do Something
}
}
AfxEndThread(0);
}
pThread=AfxBeginThread(MyThread, NULL);
close thread (Destroy Window):
if(pThread->m_hThread != (void*)0xdddddddd)
{
DeleteObject(pThread);
}
Re: question with Thread Termination
Quote:
Originally Posted by pharma
crucial: Is this a ok way to terminate a thread?.
Code:
CWinThread *pThread=NULL;
UINT MyThread(LPVOID MyParam)
{
while(1)
{
If(IsTrue)
{
//Do Something
}
}
AfxEndThread(0);
}
pThread=AfxBeginThread(MyThread, NULL);
close thread (Destroy Window):
if(pThread->m_hThread != (void*)0xdddddddd)
{
DeleteObject(pThread);
}
In case of worker thread there is no need to use AfxEndThread as the Thread Proc will return it will autometically end the thread and delete its all memory.