please dont rip this site Prev Next

SetWaitableTimer info  Overview  Group

The SetWaitableTimer function activates the specified “waitable” timer. When the due time arrives, the timer is signaled and the thread that set the timer calls the optional completion routine.

BOOL SetWaitableTimer(

    HANDLE hTimer,

// handle to a timer object

    const LARGE_INTEGER *pDueTime,

// when timer will become signaled

    LONG lPeriod,

// periodic timer interval

    PTIMERAPCROUTINE pfnCompletionRoutine,

// pointer to the completion routine

    LPVOID lpArgToCompletionRoutine,

// data passed to the completion routine

    BOOL fResume

// flag for resume state



Identifies the timer object. The CreateWaitableTimer or OpenWaitableTimer function returns this handle.
Specifies when the state of the timer is to be set to signaled, in 100 nanosecond intervals. Use the format described by the FILETIME structure. Positive values indicate absolute time. Negative values indicate relative time. The actual timer accuracy depends on the capability of your hardware.
Specifies the period of the timer, in milliseconds. If lPeriod is zero, the timer is signaled once. If lPeriod is greater than zero, the timer is periodic. A periodic timer automatically reactivates each time the period elapses, until the timer is canceled using the CancelWaitableTimer function or reset using SetWaitableTimer. If lPeriod is less than zero, the function fails.
Specifies an optional completion routine. The completion routine has the following prototype:


   LPVOID lpArgToCompletionRoutine,

   DWORD dwTimerLowValue,

   DWORD dwTimerHighValue



The argument for the completion routine is specified when the timer is made active, in the lpArgToCompletionRoutine parameter. The completion routine also takes two DWORD values that specify the high and low time values of the time at which the timer was signaled. These values are passed to the routine by the system using the FILETIME format.

For more information, see Asynchronous Procedure Calls.

Pointer to the structure that is passed to the function specified by the pointer pfnCompletionRoutine.
Specifies whether to restore a system in suspended power conservation mode when the timer state is set to signaled. If fResume is TRUE on a platform that does not support a restore, the call will succeed, but GetLastError returns ERROR_NOT_SUPPORTED.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.


Timer are initially inactive. Timers are activated by calling SetWaitableTimer. If the timer is already active when you call SetWaitableTimer, the timer is stopped, then it is reactivated. Stopping the timer in this manner does not set the timer state to signaled, so threads blocked in a wait operation on the timer remain blocked.

When the specified due time arrives, the timer becomes inactive. The state of the timer is set to signaled, the timer is reactivated using the specified period, and the thread calls the completion routine. If you call SetWaitableTimer and the thread is not in an alertable state, the completion routine is canceled.

When a manual-reset timer is set to the signaled state, it remains in this state until SetWaitableTimer is called to reset the timer. As a result, a periodic manual-reset timer is set to the signaled state when the initial due time arrives and remains signaled until it is canceled or reset. When a synchronization timer is set to the signaled state, it remains in this state until a thread completes a wait operation on the timer object.

See Also

CancelWaitableTimer, CreateWaitableTimer, FILETIME, OpenWaitableTimer  

file: /Techref/os/win/api/win32/func/src/f83_16.htm, 6KB, , updated: 2000/4/7 12:19, local time: 2023/6/1 22:21,

 ©2023 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> SetWaitableTimer</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2023 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!