Executing Callbacks in Secondary Threads
- Updated2023-02-21
- 2 minute(s) read
With some of the LabWindows/CVI libraries, you can receive callbacks in a system-created thread. Because these libraries automatically create threads that execute your callbacks, you do not have to create threads or schedule a function to run in a secondary thread. You still have to protect data that is shared between these threads and other threads in your program. Implementations of these callbacks are typically referred to as asynchronous events.
- LabWindows/CVI GPIB/GPIB 488.2 Library—Call ibnotify to register a callback that the GPIB/GPIB 488.2 Library calls when events occur. You can specify one callback function per board or device. You can specify the events for which you would like your callback to be called. The GPIB/GPIB 488.2 Library creates a thread that it uses to execute your callback.
- VISA Library—Call viInstallHandler to register one or more event handlers (callback functions) for the VISA event types (I/O completion, service request, and so on) you want to receive for a particular ViSession. The VISA Library usually uses a secondary thread that it creates to execute your callback. VISA might use the same thread for all callbacks in a process or a unique thread for each ViSession. You must call viEnableEvent for the specified event type(s) to notify the VISA Library that you want it to call the event handlers that you registered.
- LabWindows/CVI VXI Library—Each interrupt or callback type has its own callback registration and enabling functions. For example, to receive an NI-VXI interrupt, you must call both SetVXIintHandler and EnableVXIint. The VXI Library uses a secondary thread that it creates to execute your callback. The VXI Library uses the same threads for all callbacks in a particular process.
- Network Variable Library—Network variable callback functions are called on a system thread.
- Asynchronous Timers Control—The asynchronous timer control provides timer callbacks that execube in their own threads.
- NI-DAQmx Library