I have this in a header:
static volatile bool g_operational = true;
then WM_CLOSE
has this:
g_operational = false;
WaitForSingleObject(TimerDoneEvent , INFINITE);
DeleteTimerQueueEx(t_main , NULL);
with the timer callback function looking like this:
VOID CALLBACK main_timer(PVOID lpParam , BOOLEAN TimerOrWaitFired) {
// doing stuff
if ( !g_operational )
SetEvent(TimerDoneEvent);
}
The timer itself is doing what I expect but the issue is shutting it down from WM_CLOSE
, what's happening is g_operational
is set to false
then the timer thread that's running every second should pick up on g_operational
being false then call SetEvent
to signal that the thread is done so WaitForSingleObject
can continue but within the callback function g_operational
always remains true
, why is this?