({{, (RefLink[ConnectLibraryCallbackFunction, paclet:ref/ConnectLibraryCallbackFunction])[mname,cf] 
connects a (RefLink[CompiledFunction, paclet:ref/CompiledFunction]) cf with the library callback manager with name mname.}})

OpenersNotesSection(Spacer1)Details

A unique positive integer ID is generated, and the function associated with the manager with name mname is called with that ID.

(RefLink[ConnectLibraryCallbackFunction, paclet:ref/ConnectLibraryCallbackFunction])[mname,cf] returns (RefLink[True, paclet:ref/True]) if the manager function returns the mbool value True (=1).

A manager is registered by using the LibraryLink callback function (NonWLLink[registerLibraryCallbackManager, paclet:LibraryLink/ref/callback/registerLibraryExpressionManager]).

A connected function can be called using the LibraryLink callback function (NonWLLink[callLibraryCallbackFunction, paclet:LibraryLink/ref/callback/callLibraryCallbackFunction]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Load an example (RefLink[LibraryFunction, paclet:ref/LibraryFunction]) that applies a callback function to each element in a list:

applyCallback = LibraryFunctionLoad["demo_callback","apply_callback",{{Real,_}},{Real,_}];

Compile a simple function and connect the (RefLink[CompiledFunction, paclet:ref/CompiledFunction]) to the library callback manager:

cf = Compile[{{x,_Real}},Nest[3.75#(1.-#)&,x,10]]

ConnectLibraryCallbackFunction["demo_callback_manager",cf]

Applying the (RefLink[LibraryFunction, paclet:ref/LibraryFunction]) to a list will use the (RefLink[CompiledFunction, paclet:ref/CompiledFunction]) for each element:

ListPlot[applyCallback[N[Range[0,100]]/100],DataRange->{0,1}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LibraryFunction, paclet:ref/LibraryFunction])  ▪  (RefLink[CompiledFunction, paclet:ref/CompiledFunction])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[LibraryLink User Guide, paclet:LibraryLink/tutorial/Overview])}, {▪(RefLinkPlain[Library Callback Functions, paclet:LibraryLink/tutorial/InteractionWithWolframLanguage#894022691])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wolfram LibraryLink, paclet:guide/LibraryLink])}})}})