KeSetTimerEx

BOOLEAN
KeSetTimerEx(

IN PKTIMER Timer,
IN LARGE_INTEGER DueTime,
IN LONG
Period,/* optional */
IN PKDPC Dpc /* optional */
);

KeSetTimerEx sets the absolute or relative interval at which a timer object is to be set to the Signaled state, optionally supplies a CustomTimerDpc routine to be executed when that interval expires, and optionally supplies a recurring interval for the timer.

Parameters

Timer

Points to a timer object that was initialized with KeInitializeTimer or KeInitializeTimerEx.

DueTime

Specifies the absolute or relative time at which the timer is to expire. If the value of the DueTime parameter is negative, the expiration time is relative to the current system time. Otherwise, the expiration time is absolute. The expiration time is expressed in system time units (100-nanosecond intervals). Absolute expiration times track any changes in the system time; relative expiration times are not affected by system time changes.

Period

Specifies an optional period for the timer in milliseconds. Must be less than or equal to MAXLONG.

Dpc

Points to a DPC object that was initialized by KeInitializeDpc. This parameter is optional.

Return Value

If the timer object was already in the system timer queue, KeSetTimerEx returns TRUE.

Comments

KeSetTimerEx:

·Computes the expiration time.

·Sets the state of the timer to Not-Signaled.

·Sets the recurring interval for the timer, if one was specified.

·Inserts the timer object in the system timer queue.

If the timer object was already in the timer queue, it is implicitly canceled before being set to the new expiration time. A call to KeSetTimerEx before the previously specified DueTime has expired cancels both the timer and the call to the Dpc, if any, associated with the previous call.

If the Dpc parameter is specified, a DPC object is associated with the timer object. When the timer expires, the timer object is removed from the system timer queue and its state is set to Signaled. If a DPC object was associated with the timer when it was set, the DPC object is inserted in the system DPC queue to be executed as soon as conditions permit after the timer interval expires.

A DPC routine cannot deallocate a periodic timer. A DPC routine can deallocate a nonperiodic timer.

Only one instantiation of a given DPC object can be queued at any given moment. To avoid potential race conditions, the DPC passed to KeSetTimerEx should not be passed to KeInsertQueueDpc.

A caller cannot wait at raised IRQL nor in an arbitrary thread context for a timer to expire by calling KeWaitXxx.

Callers of KeSetTimerEx must be running at IRQL <= DISPATCH_LEVEL.

See Also

KeCancelTimer, KeInitializeDpc, KeInitializeTimer, KeInitializeTimerEx, KeReadStateTimer, KeWaitForMultipleObjects, KeWaitForSingleObject