Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

SetThreadpoolCallbackLibrary function

Ensures that the specified DLL remains loaded as long as there are outstanding callbacks.

Syntax


VOID SetThreadpoolCallbackLibrary(
  _Inout_  PTP_CALLBACK_ENVIRON pcbe,
  _In_     PVOID mod
);

Parameters

pcbe [in, out]

A TP_CALLBACK_ENVIRON structure that defines the callback environment. The InitializeThreadpoolEnvironment function returns this structure.

mod [in]

A handle to the DLL.

Return value

This function does not return a value.

Remarks

You should call this function if a callback might acquire the loader lock. This prevents a deadlock from occurring when one thread in DllMain is waiting for the callback to end, and another thread that is executing the callback attempts to acquire the loader lock.

If the DLL containing the callback might be unloaded, the cleanup code in DllMain must cancel outstanding callbacks before releasing the object.

Managing callbacks created with a TP_CALLBACK_ENVIRON that specifies a callback library is somewhat processing-intensive. You should consider other options for ensuring that the library is not unloaded while callbacks are executing, or to guarantee that callbacks which may be executing do not acquire the loader lock.

The thread pool assumes ownership of the library reference supplied to this function. The caller should not call FreeLibrary on a module handle after passing it to this function.

This function is implemented as an inline function.

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 (include Windows.h)

See also

DestroyThreadpoolEnvironment
FreeLibraryWhenCallbackReturns
InitializeThreadpoolEnvironment
SetThreadpoolCallbackCleanupGroup
SetThreadpoolCallbackPool
SetThreadpoolCallbackPriority
SetThreadpoolCallbackRunsLong
Thread Pools

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.