Example Code

Running Multiple Events Simultaneously within LabVIEW

Code and Documents

Attachment

Overview


Events within an Event Structure run sequentially; a second event’s code will not run until the first event’s code has finished. However, some event-driven applications need to be made such that the second event can be triggered and run before the first event’s code has completed execution. This example program demonstrates how you can trigger events that will run simultaneously.

Implementation

This example program is organized in a project containing a main VI, VIs for each specific test to be launched, and some variables.  The main VI has an Event Structure that responds to events generated by buttons on the front panel.  Buttons 1, 2 and 3 will trigger events whose code can be executed simultaneously.  This is possible because inside the Event Structure VIs are launched dynamically and the Event Structure does not wait for the dynamically launched VI to terminate before proceeding to handle the next Event.  If we had used sub VIs in the conventional manner, the main VI would wait until each sub VI finished before handling the following Event.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors