CMorgan
CMorgan

Reputation: 323

How to pause a timer created with CreateTimerQueueTimer

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

Answers (1)

Tofu
Tofu

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

Related Questions