LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a SubVI without halting execution of main thread

Solved!
Go to solution

Greetings everyone, I would like to do a rather simple demonstration VI, that opens a menu where user can call a few VIs, signal generation, signal reading and graph analysis, each contained into a SubVI and with their own front panel and controls. The idea is user can just click a button and the required SubVI will load, I am using an event structure for ease.

 

Problem is, after I open any option, said SubVI hogs the execution thread, and doesn't allow for further instances until it's closed (it's inside a while loop so it makes sense I guess), the events queue and next front panel loads only after I stop the SubVI. I would like to be able to just open the front panels and let them run in parallel, without them waiting for another to finish, is this possible?

0 Kudos
Message 1 of 5
(4,108 Views)

You'll want to do either an ansyncronous call or subpanels.

 

From what you've described here, it sounds like you'd prefer run subpanels so you don't end up popping up a bunch of windows.

Message 2 of 5
(4,091 Views)
Solution
Accepted by topic author Daikataro

natasftw is right.

A SubPanel is a "hole" in your main panel.  You "insert" a separate VI into that "hole", and then you see the panel of the inserted VI thru the hole, and mouse clicks go thru the hole to the subVI below.

 

You have to run the subVI separately, though - just inserting it does not make it run.

 

An aynchronous call will start a subVI running, and then return to the calling thread with the subVI running in parallel.

 

You can then insert the subVI into a subpanel, or let it have its own window, as you choose.

 

There are examples showing both those techniques.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 3 of 5
(4,072 Views)

You can check the example in this link :https://decibel.ni.com/content/docs/DOC-13956

This example shows how to use a producer/consumer design pattern with a queue to dynamically call multiple subVIs. The subVIs are called and then run independently of Main.vi. This means that they are running but Main.vi does not wait for them to finish executing before continuing (they are non-modal). 

Thanks
uday
0 Kudos
Message 4 of 5
(4,062 Views)

So yeah, asynchronous calls were exactly what I was looking for, thanks a bunch!

0 Kudos
Message 5 of 5
(4,015 Views)