No warnings No errors but no workie either.
I am trying to start a thread to implement a non blocking stopwatch style timer.
_beginthread never calls the function TimerGo and the Handle returned is curiously
0xcccccccc or uninitialized.
Header declaration in private section of CBCRMaster
static void TimerGo(void * p_userdata);
Thread starter in BCRMaster.cpp
HANDLE hThread = _beginthread((void)TimerGo,0,this);
TimerGo function
void CBCRMaster::TimerGo(void * ParentPtr)
{
Timer timer;
while(true) {
if(timer.elasped(3000)) {
Beep(1000,1000);
AfxMessageBox("Times Up!");
}
}
}
The timer class FWIW
class Timer {
clock_t counter;
public:
Timer(): counter(0) {};
bool elasped(clock_t ms)
{
clock_t tick = clock();
if(tick - counter >= ms)
{
counter = tick;
return true;
}
return false;
}
};