Solution
Depending on the type of inputs for Open VI Reference, the VI can only execute if the UI thread is not occupied by any other task in LabVIEW.
There are four different input combinations from which only one allows the VI to execute without a hang even if the UI thread is already occupied by another function:
- In order to prevent a hang the VI type specifier must allow a generic VI reference. A strictly typed VI reference including the connector pane information requires exclusive use of the UI thread.
- The VI is required to be called with a string and not a path data type by connecting a string to the VI path input. If you wire a path, LabVIEW waits until the user interface is idle to load the VI from disk. If you wire a name string, LabVIEW does not need to wait until the user interface is idle, as it does not load a VI from disk. This and more information can also be found in the Open VI Reference help section.
Please note:
- Using a string input to identify the VI requires that the VI is already loaded into memory. Therefore, if you are trying to load a VI dynamically, you will still need to use an Open VI Reference with a path wired to it somewhere in the code.
- Alternatively, the reference can also be opened with a static VI reference loaded into memory and then calling the VI Name string to execute Open VI Reference without a hang:
The best way to get around the threading issue is to open the VI reference at the beginning of the program, before the user has the chance to interact with the front panel causing the program to hang. Then, with the reference already open, open the front panel and/or run the VI where desired in the program.