DarkLizener
December 13th, 2004, 03:01 PM
Hi
I've got a class CDataProcess that provides the methodes to input data to an access database using ADO. While inputting the data a status dialog showing the progress is visible. BUT: How can I stop this process (e.g. via a STOP button on the status dialog). I figured it could be useful to begin a new thread so I did this:UINT Process(LPVOID pParam)
{
CDataProcess* p = (CDataProcess*)pParam;
p->ProcessData();
}
....
void CDataProcess::ProcessData(...)
{
thread = AfxBeginThread(Process,this);
}
"thread" declared in the class
This works fine as long as you don't suspend the thread. If you do this for example through the StatusDialog (that is also declared in the CDataProcess)void CStatusDlg::OnAbort()
{
CMainWnd* p = (CMainWnd*)GetParent();
p->dataproc.thread->SuspendThread();
}
the MainWnd holds a CDataProcess variable and is the parent of the StatusDialog.
Propably I made a whole mistakes but please help me. WHY do I get an error when I stop the thread????? It stops and then peng!
I've got a class CDataProcess that provides the methodes to input data to an access database using ADO. While inputting the data a status dialog showing the progress is visible. BUT: How can I stop this process (e.g. via a STOP button on the status dialog). I figured it could be useful to begin a new thread so I did this:UINT Process(LPVOID pParam)
{
CDataProcess* p = (CDataProcess*)pParam;
p->ProcessData();
}
....
void CDataProcess::ProcessData(...)
{
thread = AfxBeginThread(Process,this);
}
"thread" declared in the class
This works fine as long as you don't suspend the thread. If you do this for example through the StatusDialog (that is also declared in the CDataProcess)void CStatusDlg::OnAbort()
{
CMainWnd* p = (CMainWnd*)GetParent();
p->dataproc.thread->SuspendThread();
}
the MainWnd holds a CDataProcess variable and is the parent of the StatusDialog.
Propably I made a whole mistakes but please help me. WHY do I get an error when I stop the thread????? It stops and then peng!