You may have never heard of the UI thread or the root loop, but as a revision to the old adage goes, what you don’t know can hurt you.
LabVIEW is a naturally multithreaded application and it dynamically allocates these threads. There are five execution systems in LabVIEW, and each execution system allocates four threads for execution, per processor core by default. For a quad-core processor LabVIEW will allocate 80 execution threads; a dual-core processor has 40 execution threads, and so on. In addition to these execution threads, there exists the UI thread.
The majority of nodes in LabVIEW will have no problem executing in the 20+ execution threads mentioned above, but certain nodes in LabVIEW can only execute within the UI thread. There is a void of documentation regarding this subject, and therefore there is no real comprehensive list of functions and VIs. The trick to understanding the UI thread is knowing the basic processes that will require the thread, which are listed below:
The UI thread uses cooperative multitasking to allow simultaneous execution of nodes, and it exists on all implementations of LabVIEW: Windows, Linux, Mac, etc.
The Root Loop
It requires the UI thread to be idle before it can execute, and blocks the UI thread while it is executing.
There exists an even smaller subset of nodes in LabVIEW that require the root loop to execute. These nodes are responsible for OS-level messaging. While it is important to understand what nodes run in the UI thread, it is critical to understand what nodes run in the root loop, a few of which are listed below:
UI thread and root loop issues can be hard to track down in large applications. If a time-critical process is running poorly, and performing UI actions (clicking, dragging windows, long-click on the title bar, opening a context menu or dialog) seem to exacerbate the situation, then there is a good chance that a portion of the time-critical process is running in the UI thread and is also victim to nodes requiring root loop.
In addition to the above information, there are special cases regarding the UI thread and root loop that might not be as obvious. The following list is a good starting point for what you can implement to avoid running into issues with your application.
While this isn’t a fully comprehensive list of all the nodes and instances that will put a VI into the UI thread or invoke the root loop, hopefully it serves as a solid base of knowledge on the topic. The root loop is elusive, and often hard to debug or pin as the culprit for an issue within an application. It isn’t a bug in LabVIEW, but a consequence of OS-level messaging that can’t be avoided. With this knowledge you should feel confident in finding a solution when the UI thread and root loop don’t want to play nice.
http://www.labviewcraftsmen.com/blog/the-root-loop
http://labviewwiki.org/Lessons_learned_from_plugins
http://digital.ni.com/public.nsf/allkb/84ECA015AA496B23862565BC006C0F19
Other Resources