Calling a VI with the Run VI Method Versus Using the Call by Reference Node

Updated Aug 28, 2023

Reported In

Software

  • LabVIEW

Issue Details

What is the difference between calling a VI with the Run VI method (invoke node) and calling a VI with the Call by Reference node?

Solution

The major difference between calling by reference using the Run VI method and the Call by Reference node is the ease of programming versus the flexibility of the architecture.


When using a Call by Reference node you must wire in a strictly typed VI reference. A strictly typed VI reference includes connector pane information with data types as well as the reference to the VI. When using the Call by Reference Node, LabVIEW creates a connector pane for you underneath the node. With the Call by Reference node, you are able to take advantage of loading a VI dynamically, while having the convenience of simple wiring.

 
 
When you use the Run VI method, you are not required to use a strictly typed reference. As a result, you can pass any VI reference to this method to run it. Using the Run VI method allows for more flexibility, as it allows you to call VIs that do not have the same connector pane. This is a simple way to only open the Front Panel and run a VI. However, if you want to pass values, you will need to know the names of the Controls and their data types, which requires additional programming. The Run VI method becomes more flexible because you can pass any VI path into this setup and it will be able to open and load that VI.
Another benefit of using the Run VI method over calling a VI by reference is the ability to interact with the VI. The Run VI method allows you to interact with the VI while it is running, e.g. if it needs to be controlled or in case the outputs need to be read multiple times. Using the Call by Reference node, the connector pane will output values only once, when the VI finishes execution. It does not provide the capability to interact with a running VI.

Additional Information

If you want to call the target VI asynchronously, use the Start Asynchronous Call node instead of the Call by Reference node. This will allow the target VI to run on a separate thread.



Using the RunVI method may have the target VI run in the UI thread, which can lead to some issues if you want to have the calling VI perform adequately while the called VI is running. This happens even if you have a False constant wired to the Wait Until Done terminal. For a complete asynchronous call outside of the UI thread, you need configure the target VI's execution settings accordingly. Open the target VI, and go to to File»VI Properties, select Execution in the drop-down and choose a Preferred Execution System different than User interface and Same as caller.