Reputation: 323
I need to pause a timer created using CreateTimerQueueTimer function of win32 API but I can't find a way to pause the timer. Does anybody knows if it is possible?
Upvotes: 3
Views: 506
Reputation: 3613
I believe you can call ChangeTimerQueueTimer and set the _In_ ULONG Period
to 0. Where the _In_opt_ HANDLE TimerQueue
argument will be NULL
and the _Inout_ HANDLE Timer
will be the HANDLE retrieved from CreateTimerQueueTimer. This will execute the callback in the timer just once and stop. If you want to reactivate the timer you can ChangeTimerQueueTimer
again with the same handle providing a period greater than 0 to run periodically. There isn't specifically an API to suspend the timer but preventing it from running periodically should be the equivalent in your case. Just note that your callback will get hit once after calling ChangeTimerQueueTimer
before "suspending".
Upvotes: 5