CreateThreadpoolWait

Creates a new wait object.

Syntax

PTP_WAIT CreateThreadpoolWait(
         PTP_WAIT_CALLBACK pfnwa,
         PVOID pv,
         PTP_CALLBACK_ENVIRON pcbe
)  

Parameters

pfnwa
Type: PTP_WAIT_CALLBACK 

[in] The callback function to call when the wait completes or times out. For details, see WaitCallback.

pv
Type: PVOID 

[in, out, optional] Optional application-defined data to pass to the callback function.

pcbe
Type: PTP_CALLBACK_ENVIRON 

[in, optional] A TP_CALLBACK_ENVIRON structure that defines the environment in which to execute the callback. The InitializeThreadpoolEnvironment function returns this structure.

If this parameter is NULL, the callback executes in the default callback environment. For more information, see InitializeThreadpoolEnvironment.

Return value

Type: PTP_WAIT 

If the function succeeds, it returns a TP_WAIT structure that defines the wait object. Applications do not modify the members of this structure.If the function fails, it returns NULL. To retrieve extended error information, call GetLastError.

Remarks

To set the wait object, call the SetThreadpoolWait function.

The work item and all functions it calls must be thread-pool safe. Therefore, you cannot call an asynchronous call that requires a persistent thread, such as the RegNotifyChangeKeyValue function, from the default callback environment. Instead, set the thread pool maximum equal to the thread pool minimum using the SetThreadpoolThreadMaximum and SetThreadpoolThreadMinimum functions, or create your own thread using the CreateThread function.

Note

RegNotifyChangeKeyValue can be called from a work item by setting the REG_NOTIFY_THREAD_AGNOSTIC flag.

Requirements

Header: Declared in threadpoolapiset.h.

Library: Use kernelx.lib.