Export (0) Print
Expand All
Expand Minimize

CallbackMayRunLong function

Indicates that the callback may not return quickly.

Syntax


BOOL WINAPI CallbackMayRunLong(
  _Inout_  PTP_CALLBACK_INSTANCE pci
);

Parameters

pci [in, out]

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 only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

WinBase.h on Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Threadpoolapiset.h on Windows 8 and Windows Server 2012

Library

Kernel32.lib

DLL

Kernel32.dll

See also

DisassociateCurrentThreadFromCallback
FreeLibraryWhenCallbackReturns
LeaveCriticalSectionWhenCallbackReturns
ReleaseMutexWhenCallbackReturns
ReleaseSemaphoreWhenCallbackReturns
SetEventWhenCallbackReturns
SetThreadpoolCallbackRunsLong
Thread Pools
TrySubmitThreadpoolCallback

 

 

Community Additions

ADD
Show:
© 2014 Microsoft