Registering and Handling .NET Events
- Updated2023-02-17
- 2 minute(s) read
Registering and Handling .NET Events
To handle a .NET event, you must register for the event and create a callback VI to handle that event.
- Enable .gpal option to place diagram contents when dropped.
- Enable preview features.
- Relaunch G Web Development Software.
- Use a .NET Interface document to create a .NET object from LabVIEW NXG.
- Add the Register Event Callback node to the diagram.
- Wire the reference or object to Event on the Register Event Callback node.
- Expand Event on the Register Event Callback node and select an event.
- (Optional) Wire the data that you want to pass to the callback VI to user parameter.
-
Right-click VI Ref and select Create
Callback VI to generate a VI based on the event you select and
the data you wire to user parameter. LabVIEW NXG wires
the callback VI to VI Ref.
Note You can use an existing VI as a callback VI as long as the connector pane of that VI matches the connector pane of the event data. The callback VI must be reentrant and the reference to the callback VI must be strictly typed.
-
Open the callback VI and edit the diagram to handle the event.
Note If you want to pass any part of event data through the callback VI, you must wire event data to event data out.
Until you unregister for events, LabVIEW NXG continues to generate and queue the events as long as the VI runs, even if no Event Structure is waiting to handle them. This behavior consumes memory and can hang the VI if you enable front panel locking for the events. To avoid this, unregister for events when you no longer need to handle them using the Unregister For Events node.
Related Information
- Callback VIs
A callback VI contains code to handle a .NET event you specify.
- Registering and Handling .NET Events
To handle a .NET event, you must register for the event and create a callback VI to handle that event.
- .NET Events
.NET events are actions that affect a .NET object, such as clicking a mouse, pressing a key, or receiving notifications about running out of memory or tasks completing.
- Register Event Callback