TpSetCallbackRaceWithDll function (winnt.h)

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

Syntax

void TpSetCallbackRaceWithDll(
  [in, out] PTP_CALLBACK_ENVIRON CallbackEnviron,
  [in]      PVOID                DllHandle
);

Parameters

[in, out] CallbackEnviron

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

[in] DllHandle

A handle to the DLL.

Return value

None

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.

This function is implemented as an inline function.

Requirements

Requirement Value
Target Platform Windows
Header winnt.h

See also

TpDestroyCallbackEnviron

TpInitializeCallbackEnviron

TpSetCallbackActivationContext

TpSetCallbackCleanupGroup

TpSetCallbackFinalizationCallback

TpSetCallbackLongFunction

TpSetCallbackNoActivationContext

TpSetCallbackPersistent

TpSetCallbackPriority

TpSetCallbackThreadpool