Creating Callback Routine
Creating Callback Function
The callback function has the following format. You can specify any name for this function.
Protected Sub CallBackProc(ByVal Id As Short, ByVal wParam As Integer, ByVal lParam As Integer, ByVal Param As IntPtr)
Using Delegate
In Visual Basic, please use delegate to handle a function pointer.
The delegate declarations for each callback routine are written in the CDIO.vb file.
Trigger Monitor |
PTRGCALLBACK |
Interrupt Input |
PINTCALLBACK |
Registering Callback Function
Please use the following functions to register callback functions.
Trigger Monitor |
DioSetTrgCallBackProc |
Interrupt Input |
DioSetInterruptCallBackProc |
Flow of Registering Callback Function
.Initializing delegate
.To prevent the garbage collector from moving the delegate used for interrupt processing, get the GCHandle
.Get a stable pointer to the delegate used for interrupt processing
.Register the retrieved stable pointer by using functions such as DioSetInterruptCallBackProc function
.Release the GCHandle for the delegate used for interrupt processing, when it become unnecessary (for example, when the application terminates)
For these specific coding content, please refer to samples and Note of Using Visual Basic .NET.