Table Of Contents

Registering and Handling .NET Events

    Last Modified: November 20, 2020

    To handle a .NET event, you must register for the event and create a callback VI to handle that event.

    Before you begin, complete the following prerequisite tasks: Complete the following steps to register and handle .NET events.
    1. Use a .NET Interface document to create a .NET object from LabVIEW NXG.
    2. Add the Register Event Callback node to the diagram.
    3. Wire the reference or object to Event on the Register Event Callback node.
    4. Expand Event on the Register Event Callback node and select an event.
    5. (Optional) Wire the data that you want to pass to the callback VI to user parameter.
    6. 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.

      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.

    7. Open the callback VI and edit the diagram to handle the event.

      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.

    Recently Viewed Topics