|
-
September 7th, 2004, 11:59 PM
#1
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);
}
-
September 8th, 2004, 12:21 AM
#2
Re: question with Thread Termination
 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.
Unmanaged in a .NET world
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|