N
Nils
Hi,
I have some problems with threads.
I have a class thats start a thread. After thread the class should wait
nutil the thread is finish. I tried it like this:
----------------------------------------------------------------------------
--------------------------------
void CGeo2View:nInsertObjects()
{
.....
CGeo2View::c_threadFinish=false;
CWinThread *thread=AfxBeginThread(onInsertObjectsThread,vec,1,0,0,NULL);
while(CGeo2View::c_threadFinish==false)
{
;
}
.....
}
----------------------------------------------------------------------------
--------------------------------
}
UINT CGeo2View:nInsertObjectsThread(LPVOID pPara)
{
....
CGeo2View::c_threadFinish=true;
return 1;
....
}
----------------------------------------------------------------------------
--------------------------------
But after the while-loop starts it never ends.
I thought the reason could be as followed:
When the thread tries to set c_threadFinish to true, the while-loop reads
the varibale, so the it never set to "true"
Is that right?
So I tried it with the CEvent - Class. But can't implement it.
Can anyone tell how it will work in the exampla above.
Thank you
I have some problems with threads.
I have a class thats start a thread. After thread the class should wait
nutil the thread is finish. I tried it like this:
----------------------------------------------------------------------------
--------------------------------
void CGeo2View:nInsertObjects()
{
.....
CGeo2View::c_threadFinish=false;
CWinThread *thread=AfxBeginThread(onInsertObjectsThread,vec,1,0,0,NULL);
while(CGeo2View::c_threadFinish==false)
{
;
}
.....
}
----------------------------------------------------------------------------
--------------------------------
}
UINT CGeo2View:nInsertObjectsThread(LPVOID pPara)
{
....
CGeo2View::c_threadFinish=true;
return 1;
....
}
----------------------------------------------------------------------------
--------------------------------
But after the while-loop starts it never ends.
I thought the reason could be as followed:
When the thread tries to set c_threadFinish to true, the while-loop reads
the varibale, so the it never set to "true"
Is that right?
So I tried it with the CEvent - Class. But can't implement it.
Can anyone tell how it will work in the exampla above.
Thank you