NdisMSetTimer function

Note NDIS 5. x has been deprecated and is superseded by NDIS 6. x. For new NDIS driver development, see Network Drivers Starting with Windows Vista. For information about porting NDIS 5. x drivers to NDIS 6. x, see Porting NDIS 5.x Drivers to NDIS 6.0.

NdisMSetTimer sets a timer to fire after a specified interval, thereby running an associated MiniportTimer function when the timer fires.


VOID NdisMSetTimer(
  _In_ UINT                 MillisecondsToDelay


  • Timer [in]
    Pointer to caller-supplied resident storage for a timer object previously initialized with NdisMInitializeTimer.

  • MillisecondsToDelay [in]
    Specifies the interval, in milliseconds, to time out before calling the MiniportTimer function.

Return value



NdisMSetTimer causes the driver-supplied MiniportTimer function, which was associated with the timer object when MiniportInitialize called NdisMInitializeTimer, to run once after the given MillisecondsToDelay expires. Execution of the MiniportTimer function associated with the Timer passed to NdisMSetTimer is episodic, rather than periodic. A miniport driver must call NdisMSetTimer each time the associated timer function should be run.

By contrast, NdisMSetPeriodicTimer causes the associated MiniportTimer function to be run repeatedly whenever the given MillisecondsPeriod expires. At the initial call to NdisMSetPeriodicTimer, the timer object is queued until the MillisecondsPeriod expires, when the MiniportTimer function is run and the timer object is automatically requeued for the next interval.

As a general rule, a miniport driver should allocate and initialize two timer objects if it calls both NdisMSetPeriodicTimer and NdisMSetTimer. Such a driver is likely to have two MiniportTimer functions with different functionality, each associated with a particular timer object when it is initialized with NdisMInitializeTimer. For example, a MiniportTimer function that runs periodically might poll device state at regular intervals, while another MiniportTimer function might retry a particular run-time operation only if it times out on the NIC.

If a miniport driver calls NdisMSetTimer, NdisMCancelTimer, or NdisMSetPeriodicTimer with the same Timer pointer originally passed to NdisMSetTimer before the originally specified MillisecondsToDelay has expired, the current call cancels its preceding call to NdisMSetTimer. Any call to NdisMSet..Timer resets the given timer to expire at the interval specified in the most recent call and causes the associated MiniportTimer function to run when the most recently specified interval has expired.

Timer resolution on the host varies. Consequently, calling NdisMSetTimer with very small time-out values does not necessarily cause the execution of the MiniportTimer function exactly when the specified interval expires. The minimum practicable interval to specify on Windows 2000 and later platforms is ten milliseconds.


Target platform



Not supported for NDIS 6.0 drivers in Windows Vista. Use NdisSetTimerObjectinstead. Supported for NDIS 5.1 drivers in Windows Vista and Windows XP.


Ndis.h (include Ndis.h)





See also






Send comments about this topic to Microsoft