Class DllCallback() Foundation

Class function of the DllCallback class

Description

Instances of the DllCallback class are used for allowing Xbase++ code to be called as callback functions from inside a DLL function, for example, an operating system API.

When a DLL function that requires a callback function is executed via DllExecuteCall(), the Xbase++ code to be executed in the callback must be specified in the form of an DllCallback object. This is done by assigning the callback object to the corresponding parameter of the DLL function, which must be declared of type DLL_TYPE_CALLBACK or DLL_TYPE_ACALLBACK when preparing the call usingDLLPrepareCall().

The Xbase++ code can either be defined in the :execute() method in a class derived from DllCallback, or it can be implemented in a separate function. See the :new() method for further information.

Both synchronous and asynchronous callbacks are supported. A synchronous callback is used only during the execution of the DLL function, whereas an asynchronous callback function can still be executed after the DLL function returns.

A synchronous callback is automatically freed before DllExecuteCall() returns. A callback which is used asynchonously, however, must be freed explicitly by the application using the method :destroy().

Threading: A synchronous callback typically executes in the thread that executes the DLL function via DllExecuteCall(). In this case, thread-local resources such as work areas can be assumed to be accessible when the callback executes. However, callbacks which are run asynchronously often execute in separate threads, which means thread-local resources are not available. Please check the documentation of your DLL function or API for more information about the context the callback executes in.

Class methods
:new()
Initializes a callback object.
Live cycle
:create()
Requests resources for the callback object.
:destroy()
Releases resources of the callback object.
Invocation
:execute()
The callback to be executed by the Dll function.
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.