SubVI Continues to Run When I Stop the Main VI

Updated May 4, 2018

Reported In


  • LabVIEW

Issue Details

In LabVIEW, my main VI has one or more sub-processes that run parallel to my main code within a subVI. When I press the stop button on my main VI, the main VI stops, but the processes in the subVIs continue to run. How can I get the subVIs to stop running at the same time as the main VI?

How can I stop multiple VIs using a single stop button?


If a subVI is running a loop in parallel to the main VI code, then the subVI can be stopped by passing the value of the stop button into the subVI. While a wire could be used to pass this data to the subVI, it is often undesirable because it creates a dependency between the main VI loop and the subVI which will cause the processes to not be truly parallel.

One common alternative is to use a global variable to pass the value of the stop button into the subVI asynchronously. The following code images show how this might be done. A copy of this code Is also attached:

Main VI:


Additional Information

This problem will only occur when your subVI has its own loop structure. While this may be an appropriate design for some applications, it is sometimes possible to replace it with a simpler design.

One alternative may be to remove the loop from the subVI and then include the subVI within the loop of the main VI. In this method, the subVI will run a single iteration each time the main VI loops. In this case, the subVI would not continue to run once the main VI has completed.