Choosing How the Event Structure Monitors For Events
- Updated2025-01-22
- 3 minute(s) read
Choosing How the Event Structure Monitors For Events
LabVIEW can generate many different events. Use event registration to specify which events you want an Event structure to handle. When you register for an event, LabVIEW notifies you when that particular event occurs. In LabVIEW, you can register for an event statically or dynamically. With static registration, LabVIEW always queues the event and notifies you when the event occurs. For example, if you statically register for a Mouse Move event on a front panel control, LabVIEW queues this event every time the user moves the mouse over that control. With dynamic registration, you can design applications so that LabVIEW only queues the event and notifies you when the event occurs if that event occurs under the circumstances you specify. For example, you may not want to monitor the Mouse Move event until the user presses a certain key. You also can use dynamic registration to change which VIs or controls generate events and to handle events in a subVI rather than the VI where LabVIEW generates events.
Static Event Registration
LabVIEW automatically performs static registration when you run a VI that contains an Event structure. You can configure an Event structure to specify which user interface events on the front panel of a VI you want to handle in each Event structure case. Use the Edit Events dialog box to configure an Event structure to handle a statically registered event.
Refer to examples\Structures\Event Structure\Event Structure.lvproj for examples of using static event registration.
Dynamic Event Registration
Dynamically registering for events allows you to control when LabVIEW generates events, which events LabVIEW generates, and where LabVIEW handles those events. Dynamic event registration provides the following benefits:
- You can control when LabVIEW generates events by registering for events during different parts of an application. For example, you may want to monitor only certain events under certain circumstances, like mouse movement over a graph after the user clicks a button that plots data to the graph. With static registration, the Mouse Move event always occurs. With dynamic event registration, you can register for the Mouse Move event after the user clicks the button to plot data to the graph.
- At run time, you can change which VIs or controls generate events. To change the objects for which LabVIEW generates events, modify the registration information at run time.
- LabVIEW can generate events without direct user interaction with the front panel. With dynamic event registration, you can design an application to make programmatic changes, like updating the value of a control from the block diagram, and LabVIEW generates events for these changes. Static event registration requires user interaction for LabVIEW to generate events.
- You can handle events in a subVI rather than only in the VI where you generate the events, which provides modularity to the application. For example, in a DAQ application, you can create a subVI to handle all of the user interface events, a subVI to handle all custom events, and a subVI to handle all DAQ events for the entire application rather than handling all events in the VI where the events are generated.