Visual Basic .NET

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 CCNT.vb file.
 

Count Match Notification

PCOUNTUPCALLBACK

Counter Error Notification

PCOUNTERERRORCALLBACK

Carry/Borrow Notification

PCARRYBORROWCALLBACK

Timer Notification

PTIMERCALLBACK

Sampling Stop Notification

PSAMPLINGSTOPCALLBACK

Specified Time Sampling Completion

PSAMPLINGCOUNTCALLBACK

Registering Callback function

Please use the following functions to register callback functions.

Count Match Notification

CntCountUpCallbackProc

Counter Error Notification

CntCounterErrorCallbackProc

Carry/Borrow Notification

CntCarryBorrowCallbackProc

Timer Notification

CntTimerCallbackProc

Sampling Stop Notification

CntSamplingStopCallbackProc

Specified Time Sampling Completion

CntSamplingCountCallbackProc

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 CntCountUpCallbackProc function
- Release the GCHandle for the delegate used for interrupt processing, when it become unnecessary (for example, when the application terminates)

For the details of coding, please refer to sample programs and Note of Using Visual Basic .NET.