Property Sheet (please help)
Hello,
I have a problem which I have not been able to solve for a
whole 2 days. I have a dialog program but I changed it to launch a
modal property sheet instead of a dialog. I have added property pages
(each page as a separate class) to this property sheet successfully.
The property sheet has a Cancel button at the bottom.
In the property sheet I have a worker thread. If I do not access
functions in the pages of the property sheet, I am able to exit the
thread just fine. But if I am running something in a page, then I am
not able to exit the thread successfully. It just stalls the app.
Any idea why this is the case? All my pages are organized as separate
classes and I make an object of them in my property sheet (the parent
class). So what is the problem?
I desparately need help on this as its beginning to exhaust me. Thank
you.
---------------
// how I start the thread
void CPropSheet::StartThread(void)
{
pthread=AfxBeginThread(Packrat,this,THREAD_PRIORITY_NORMAL, 0,
CREATE_SUSPENDED);
pthread->m_bAutoDelete = true;
exitthread = 0;
pthread->ResumeThread(); // runs functions in certain pages of the
property sheet
}
// the thread
UINT Packrat( LPVOID pParam )
{
CPropSheet *p = (CPropSheet*)pParam;
while(exitthread != 1)
{
p->RecvData(); // gets incoming data
}
exitthread = 5;
return 0;
}
// how I exit the thread
void CPropSheet::EndThread(void)
{
exitthread = 1;
while(exitthread != 5);
}