This topic has not yet been rated - Rate this topic

SetThreadpoolWait function

Applies to: desktop apps only

Sets the wait object. A worker thread calls the wait object's callback function after the handle becomes signaled or after the specified timeout expires.

Syntax

VOID WINAPI SetThreadpoolWait(
  __inout   PTP_WAIT pwa,
  __in_opt  HANDLE h,
  __in_opt  PFILETIME pftTimeout
);

Parameters

pwa [in, out]

A pointer to a TP_WAIT structure that defines the wait object. The CreateThreadpoolWait function returns this structure.

h [in, optional]

A handle.

If this parameter is NULL, the wait object will cease to queue new callbacks (but callbacks already queued will still occur).

If this parameter is not NULL, it must refer to a valid waitable object. If this handle is closed while the wait is still pending, the function's behavior is undefined.

pftTimeout [in, optional]

A pointer to a FILETIME structure that specifies the absolute or relative time at which the wait operation should time out. If this parameter points to a positive value, it indicates the absolute time since January 1, 1601 (UTC), in 100-nanosecond intervals. If this parameter points to a negative value, it indicates the amount of time to wait relative to the current time. For more information about time values, see File Times.

If this parameter points to 0, the wait times out immediately. If this parameter is NULL, the wait will not time out.

Return value

This function does not return a value.

Remarks

You must re-register the event with the wait object before signaling it each time to trigger the wait callback.

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

Examples

For an example, see Using the Thread Pool Functions.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

CloseThreadpoolWait
CreateThreadpoolWait
Thread Pools
WaitForThreadpoolWaitCallbacks

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Ordering not crucial
When I call this API with an event that is currently set, the wait-callback is still triggered.
--
That makes sense. The wait is satisfied immediately. (The alternative - requiring the event to be reset then set again - creates a race condition.)