Open VI Reference Hangs While I Select Menu or Press Front Panel Button

Updated Aug 9, 2019

Reported In

Software

  • LabVIEW

Issue Details

When I run my VI and interact with the front panel, e.g. pressing a button or entering a menu or dialog box, Open VI Reference hangs and does not execute until I finish the front panel user action or close the according menu or dialog.

What causes this issue and how can I prevent my program execution to hang when trying to open a VI reference?
 

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:
 
  1. 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.
  2. 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.

Additional Information

  • In general LabVIEW supports multithreading but certain functions and nodes within LabVIEW can only execute within the UI thread. Whereas the UI thread can cooperatively multitask many of these functions in parallel, there are certain functions and nodes that can only execute if the UI thread is not occupied by any other task. This requirement is also referred to as the root loop (external link).
  • For nodes within LabVIEW, the context help provides information if the according function may require the root loop with the additional note "Must wait until user interface is idle: Yes"

WAS THIS ARTICLE HELPFUL?

Not Helpful