CallbackMayRunLong function

Indicates that the callback may not return quickly.

Syntax

BOOL CallbackMayRunLong(
  PTP_CALLBACK_INSTANCE pci
);

Parameters

pci

A TP_CALLBACK_INSTANCE structure that defines the callback instance. The structure 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 spin up 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 spin up a new thread. The thread pool will attempt to spin up 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

   
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

DisassociateCurrentThreadFromCallback

FreeLibraryWhenCallbackReturns

LeaveCriticalSectionWhenCallbackReturns

ReleaseMutexWhenCallbackReturns

ReleaseSemaphoreWhenCallbackReturns

SetEventWhenCallbackReturns

SetThreadpoolCallbackRunsLong

Thread Pools

TrySubmitThreadpoolCallback