c++ - Delete timer-queue timer -
i can't delete timer queue properly. following error: unhandled exception @ 0x77a915de in timer.exe: 0xc0000005: access violation reading location 0x00000020.
i have simple timer callback function:
void callback timerproc(void* lpparameter, boolean timerorwaitfired) { cout << "the timer working!" << endl; }
and here main function create , delete timer:
int main(int argc, char *argv[]) { handle htimer; // create timer createtimerqueuetimer( &htimer, // timer handler null, // default timerqueue (waitortimercallback)timerproc, // callback function 0, 0, (dword)2000, // period value = 2 seconds wt_executeintimerthread ); // other tasks // e.g. sleep(10000); // delete timer if ( !deletetimerqueueex(htimer, null) ) { cout << getlasterror() << endl; } return 0; }
the debugger stops @ deletetimerqueueex line. why failure occurs?
you not creating own queue (createtimerqueue
) rather adding default timer queue not deletable, instead delete timer (deletetimerqueuetimer
).
if want group multiple timers, create own queue can subsequently delete.
Comments
Post a Comment