spsj21
February 26th, 2009, 11:50 PM
Hi everybody!
I am trying to suspend and resume a thread using two 'Menu' buttons 'Start' & 'Stop'. I have created the thread as below
CWinThread *PWinThread;
OnCreate()
{
int Code = 1;
PWinThread = AfxBeginThread(ThreadFunction, &Code);
}
OnStart()
{
PWinThread->ResumeThread();
}
OnStop()
{
DWORD ExitCode;
PWinThread->SuspendThread();
::GetExitCodeThread(PWinThread->m_hThread, &ExitCode);
if(ExitCode == STILL_ACTIVE)
::MessageBox(0,"Thread","Is still Running",0);
}
When i click on 'Stop' button, I get the messagebox indicating that thread is still active.........can somebody trace it out please..............
I am trying to suspend and resume a thread using two 'Menu' buttons 'Start' & 'Stop'. I have created the thread as below
CWinThread *PWinThread;
OnCreate()
{
int Code = 1;
PWinThread = AfxBeginThread(ThreadFunction, &Code);
}
OnStart()
{
PWinThread->ResumeThread();
}
OnStop()
{
DWORD ExitCode;
PWinThread->SuspendThread();
::GetExitCodeThread(PWinThread->m_hThread, &ExitCode);
if(ExitCode == STILL_ACTIVE)
::MessageBox(0,"Thread","Is still Running",0);
}
When i click on 'Stop' button, I get the messagebox indicating that thread is still active.........can somebody trace it out please..............