A possible usage model :) :
...
class CYourDlg : public CDialog
{
...
static CSemaphore sm_cSemaphore;
static DWORD WINAPI EntertainmentProc(CYourDlg* pcDlg);
...
void ProcessPyrotechnics();
...
public:
...
};
...
...
CSemaphore CYourDlg::sm_cSemaphore(0, 2);
DWORD WINAPI CYourDlg::EntertainmentProc(CYourDlg* pcDlg)
{
if (pcDlg) {
while (pcDlg->m_bWorkerRunning) {
CSingleLock cLock(&sm_cSemaphore);
cLock.Lock();
if (pcDlg->m_bWorkerRunning) {
pcDlg->ProcessPyrotechnics();
}
cLock.Unlock();
...
}
}
return 0;
}
...