CallbackMayRunLong function (threadpoolapiset.h)

Indicates that the callback may not return quickly.

Syntax

BOOL CallbackMayRunLong(
  [in, out] PTP_CALLBACK_INSTANCE pci
);

Parameters

[in, out] pci

A pointer to a TP_CALLBACK_INSTANCE structure that defines the callback instance. The pointer is passed to the callback function.

Return value

The function returns TRUE if another thread in the thread pool is available for processing callbacks or the thread pool was able to create a new thread. In this case, the current callback function may use the current thread indefinitely.

The function returns FALSE if another thread in the thread pool is not available to process callbacks and the thread pool was not able to create a new thread. The thread pool will attempt to create a new thread after a delay, but if the current callback function runs long, the thread pool may lose efficiency.

Remarks

The thread pool may use this information to better determine when a new thread should be created.

The CallbackMayRunLong function should be called only by the thread that is processing the callback. Calling this function from another thread may cause a race condition.

The CallbackMayRunLong function always marks the callback as long-running, whether or not a thread is available for processing callbacks or the threadpool is able to allocate a new thread. Therefore, this function should be called only once, even if it returns FALSE.

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

Requirements

Requirement Value
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.h on Windows 7, Windows Server 2008 Windows Server 2008 R2)
Library Kernel32.lib
DLL Kernel32.dll

See also

DisassociateCurrentThreadFromCallback

FreeLibraryWhenCallbackReturns

LeaveCriticalSectionWhenCallbackReturns

ReleaseMutexWhenCallbackReturns

ReleaseSemaphoreWhenCallbackReturns

SetEventWhenCallbackReturns

SetThreadpoolCallbackRunsLong

Thread Pools

TrySubmitThreadpoolCallback