Sickboy
November 5th, 2004, 10:17 AM
I've got a worker thread which invalidates my Window-Screen and get a message from On_Paint if painting is done.
My thread works in this way:
UINT myThread::ThreadMain()
{
for (int i = 0; i < TrialAnzahl; i++)
{
p_dialog->Trial = i;
bDCPainted = false;
if (iMissedTrials==p_daten->iMaxMissingTrials)
{
AfxMessageBox(text, NULL, MB_OK);
iMissedTrials = 0;
}
Timer.starttimer();
p_dialog->Invalidate();
while(!bDCPainted){};
Timer.stoptimer();
dur = Timer.timeintv();
Timer.startMyWaitableTimer(dDisplayInterval-dur);
}
}
my OnPaint like this:
void CPoffenbergMFCDlg::OnPaint()
{
if (IsIconic())
{...}
else
{
Display(Trial);
meinThread.bDCPainted = true;
}
}
If i release my application i get following problem:
- Sometimes it happens that p_dialog->Invalidate(); has been called but bDCPainted isn't true, so that my Thread hang at while(!bDCPainted){};
In debug mode it works :confused:
Anyone knows a better (working) way ?
thx
daSickboy
My thread works in this way:
UINT myThread::ThreadMain()
{
for (int i = 0; i < TrialAnzahl; i++)
{
p_dialog->Trial = i;
bDCPainted = false;
if (iMissedTrials==p_daten->iMaxMissingTrials)
{
AfxMessageBox(text, NULL, MB_OK);
iMissedTrials = 0;
}
Timer.starttimer();
p_dialog->Invalidate();
while(!bDCPainted){};
Timer.stoptimer();
dur = Timer.timeintv();
Timer.startMyWaitableTimer(dDisplayInterval-dur);
}
}
my OnPaint like this:
void CPoffenbergMFCDlg::OnPaint()
{
if (IsIconic())
{...}
else
{
Display(Trial);
meinThread.bDCPainted = true;
}
}
If i release my application i get following problem:
- Sometimes it happens that p_dialog->Invalidate(); has been called but bDCPainted isn't true, so that my Thread hang at while(!bDCPainted){};
In debug mode it works :confused:
Anyone knows a better (working) way ?
thx
daSickboy