Hmmm. There may be more examples, but this one might do for a start. I shudder to think what would happen if I tried to make it header condition based. It's probably not possible:
Code:
for(;;)
{
if (bCancel)
{
bCountCancel = true;
bFindCancel = true;
for(;;) // Must wait until threads complete
{
if (bCountFinished && bFindFinished) break;
Sleep(100);
}
DoCancel(i, pFiles);
goto Exit;
}
if (!bCountFinished && !bFindFinished) // None of threads are finished
{
CString strFormat;
Stuff::RequestData::CountFiles();
strFormat.Format(_T("Searching for files in the specified directory. Please wait. So far, %I64u files has been found."), nTotalFiles);
m_Searching.SetWindowText(strFormat);
Sleep(500);
continue;
}
if (bCountFinished)
{
CString strFormat;
strFormat.Format(_T("Collecting files. Please wait. %I64u files were found."), nTotalFiles);
m_Searching.SetWindowText(strFormat);
Stuff::RequestData::FindFiles();
m_fProgress = (float)nCurrentFile / nTotalFiles * 100;
Sleep(100);
}
if (bFindFinished) break;
}
I'll see if I can find any better examples.