Start and Run Two VIs Simultaneously in LabVIEW

Updated Oct 25, 2023

Environment

Software

  • LabVIEW

  • I would like to programmatically start and run multiple VIs at the same time. How can I do this?
  • I would like to call a VI, but end the call, passing control back to the calling VI, but still keep the VI running.

You can use a single VI to call any number of other subVIs by using the VI Server. The top-level VI will run as a "parent" VI, while all the called VIs run as "child" VIs. The following solution scales to large numbers of subVIs as well. Follow the steps below to call a subVI from within a top-level VI:
 
  1. Retrieve the path to the subVI you would like to run.
    • For example, we have used Strip Path and Build Path with the current VI's path to specify a subVI titled MyVI_2.vi that is located in the same folder as the calling VI. However, you can specify a VI located along any valid path in your system. See Related Links to learn more about specifying file paths in LabVIEW.
  2. Use the Open VI Reference.vi (located in the Programming»Application Control palette) in your top-level VI to obtain a reference to the VI you would like to run.
  3. Wire the reference to an Invoke Node (located in the same palette) with the Run VI method selected, which will run the subVI you have specified.
    • By wiring a false constant into the Wait Until Done property, we can prevent the calling VI from stalling while the subVI runs. As you might guess, this allows the two VIs to execute simultaneously.
  4. To show the child subVI's front panel, insert another Invoke Node into the chain and use the Open FP method to display the subVI's front panel on your desktop. If you do not call this method, your subVI will still run in the background.
 

Additional Information

There are multiple ways of running other VIs in LabVIEW from another VI. Here are some of them:
  • Static call from the block diagram. This is when one VI is dropped in another VI's block diagram as a function. LabVIEW waits for the subVI to finish executing so it can collect the results. This is the most common way of using subVIs in LabVIEW.
  • Dynamic calls can be made with different options: This is when instead of dropping a function in the block diagram, we select the path to the VI we want to run and use a reference to do so. You can find an example in the solution of this document.
    • Call and Collect: Use this option when you want to collect the results of an asynchronous call to a target VI with the Wait On Asynchronous Call node. If you use this option flag, you must include one Wait On Asynchronous Call node for every call that you begin with a Start Asynchronous Call node to ensure that LabVIEW does not retain any started calls in memory indefinitely. You can find an example under LabVIEW's Help tab > Find Examples.. > Programatically Controlling VIs > Dynamically Loading and Calling VIs > Asynchronous Call and Collect.vi
    • Call and Forget: Use this option when you want to call a target VI asynchronously with the Start Asynchronous Call node but you do not need to know when or what the VI returns.You can find an example under LabVIEW's Help tab > Find Examples.. > Programatically Controlling VIs > Dynamically Loading and Calling VIs > Asynchronous Call and Forget.vi