Platform SDK: DLLs, Processes, and Threads |
The CreateTimerQueueTimer function creates a timer-queue timer. This timer expires at the specified due time, then after every specified period. When the timer expires, the callback function is called.
BOOL CreateTimerQueueTimer( PHANDLE phNewTimer, // handle to timer HANDLE TimerQueue, // handle to timer queue WAITORTIMERCALLBACK Callback, // timer callback function PVOID Parameter, // callback parameter DWORD DueTime, // timer due time DWORD Period, // timer period ULONG Flags // options );
If this parameter is NULL, the timer is associated with the default timer queue.
Value | Meaning |
---|---|
WT_EXECUTEINTIMERTHREAD | The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations. |
WT_EXECUTEINIOTHREAD | The callback function is queued to an I/O worker thread. This flag should be used if the function should be executed in a thread that waits in an alertable state.
The callback function is queued as an APC. Be sure to address reentrancy issues if the function performs an alertable wait operation. |
WT_EXECUTEINPERSISTENTTHREAD | The callback function is queued to a thread that never terminates. This flag should be used only for short tasks or it could affect other timer operations.
Note that currently no worker thread is persistent, although no worker thread will terminate if there are any pending I/O requests. |
WT_EXECUTELONGFUNCTION | Specifies that the callback function can perform a long wait. This flag helps the system to decide if it should create a new thread. |
WT_EXECUTEONLYONCE | The timer will be set to the signaled state only once. |
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.
If the DueTime and Period parameters are both nonzero, the timer will be signaled first at the due time, then periodically. The callback is called every time the period elapses, whether or not the previous callback has finished executing.
To cancel a timer, call the DeleteTimerQueueTimer function. To cancel all timers in a timer queue, call the DeleteTimerQueueEx function.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Synchronization Overview, Synchronization Functions, CreateTimerQueue, DeleteTimerQueueEx, DeleteTimerQueueTimer, Thread Pooling