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
CCAN.vb file.
Notify that there is received data |
PEVENTCALLBACK |
Registering Callback function
Please use the following function to register callback function.
Notify that there is received data |
CanNotifyEvent |
Flow of registering Callback function
- Initializing delegate
- Obtain GCHandle for interrupt handling delegate to prevent garbage collection
- Get the fixed pointer of the interrupt handler delegate
- Register the obtained fixed pointer using the callback function registration
function CanNotifyEvent
- Release the GCHandle for the interrupt handling delegate when it is no
longer needed (such as when the application ends)
For the details of coding, please refer to sample programs and Note of Using Visual Basic .NET.