CloseThreadpoolTimer function

Releases the specified timer object.

Syntax

void CloseThreadpoolTimer(
  PTP_TIMER pti
);

Parameters

pti

A TP_TIMER structure that defines the timer object. The CreateThreadpoolTimer function returns this structure.

Return Value

This function does not return a value.

Remarks

The timer object is freed immediately if there are no outstanding callbacks; otherwise, the timer object is freed asynchronously after the outstanding callback functions complete.

In some cases, callback functions might run after CloseThreadpoolTimer has been called. To prevent this behavior:

  1. Call the SetThreadpoolTimer function with the pftDueTime parameter set to NULL and the msPeriod and msWindowLength parameters set to 0.
  2. Call the WaitForThreadpoolTimerCallbacks function.
  3. Call CloseThreadpoolTimer.
If there is a cleanup group associated with the timer object, it is not necessary to call this function; calling the CloseThreadpoolCleanupGroupMembers function releases the work, wait, and timer objects associated with the cleanup group.

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or higher.

Requirements

   
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header threadpoolapiset.h (include Windows 7, Windows Server 2008 Windows Server 2008 R2, Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also

CreateThreadpoolTimer

IsThreadpoolTimerSet

SetThreadpoolTimer

Thread Pools

WaitForThreadpoolTimerCallbacks