anima_sg
March 24th, 2004, 11:42 PM
i want to create a UI thread and then end it When i terminate the uI thread by placing WM_QUIT in the message queue and the calling delete on the CWinthread object i get error. If i don't call delete i am worried about the memory leak. can some one help me out
m_pBlankWin - CWinThread
//To start the thread
if(m_pBlankWin==NULL)
{
m_pBlankWin=AfxBeginThread (RUNTIME_CLASS (CBlankThread),0,0,CREATE_SUSPENDED);
m_pBlankWin->m_bAutoDelete=false;
m_pBlankWin->ResumeThread();
}
}
//to terminate the code
if(m_pBlankWin!=NULL)
{
DWORD dwExitcode;
::GetExitCodeThread(m_pBlankWin->m_hThread,&dwExitcode);
if(dwExitcode==STILL_ACTIVE)
{
::PostThreadMessage(m_pBlankWin->m_nThreadID,WM_QUIT,0,0);
delete m_pBlankWin;
}
m_pBlankWin=NULL;
}
m_pBlankWin - CWinThread
//To start the thread
if(m_pBlankWin==NULL)
{
m_pBlankWin=AfxBeginThread (RUNTIME_CLASS (CBlankThread),0,0,CREATE_SUSPENDED);
m_pBlankWin->m_bAutoDelete=false;
m_pBlankWin->ResumeThread();
}
}
//to terminate the code
if(m_pBlankWin!=NULL)
{
DWORD dwExitcode;
::GetExitCodeThread(m_pBlankWin->m_hThread,&dwExitcode);
if(dwExitcode==STILL_ACTIVE)
{
::PostThreadMessage(m_pBlankWin->m_nThreadID,WM_QUIT,0,0);
delete m_pBlankWin;
}
m_pBlankWin=NULL;
}