LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running a sub vi inside a while loop and continuing loop execution without waiting for sub vi to complete execution

I have a main VI wich calls a "dialog-type" vi wich is supposed to sit and display certain information until the user closes the window.  The main vi runs a continuous while loop, inside that loop there is a condition check, it it's true it will launch the sub vi.  The problem is that when the sub vi is launched and active the main application sits and waits for the sub vi to finish executing and return control to it.  I need to have the sub vi window open and still continue running the code on the main vi.  Can anybody offer any suggestions?
 
Thanks
Rob
0 Kudos
Message 1 of 6
(4,120 Views)
Does the subVI depend on data from within the loop and/or needs to return data to the calling program?. In this case, just make sure the subVI immediately finishes, but set the call up to not close the front panel when it complets. This way it will stay there, and display fresh data whever it gets called again in the next iteration.
 
No matter what, I would not set the windows properties to "dialog" if you still want to operate the main VI while the subVI is there.
 
If the subVI does not depend on fresh data from the loop, there is no reason to lauch it from within that loop. Just use a parallel loop with an event structure to lauch that subVI. 
0 Kudos
Message 2 of 6
(4,111 Views)

It kinda does.  The main VI updates data to a global variable.  The sub vi's purpose is to alert the user that there is a channel in "alarm".  I could make it do what you suggest but I also need an "close window" button that would close the sub vi front panel when the user clicks on it.  So the sub vi has a case structure which sits there and waits for the user to click on the "close window" button to complete its execution and hence close itself.  is there another way to do this?  I suppose i could make the user close the vi using the red 'x' provided by windows but I must use some sort of "ok" or "close window" button on the sub vi's front panel.

 

Thanks

0 Kudos
Message 3 of 6
(4,105 Views)
You could have the subVI always running, and just switch the visibility of its front panel.
0 Kudos
Message 4 of 6
(4,097 Views)
Yeah that was my last resort.  I kinda wanted to see if there was a better or easier way to do it.  Thanks for the help.
0 Kudos
Message 5 of 6
(4,088 Views)

FWIW, I'd advise that you go with altenbach's first suggestion and simply require users to click the Windows' standard top-right-corner 'x' to close the pop-up.  I've done similar things to handle certain types of fault notification.  It's an easier implementation if you're fairly new to LabVIEW.

To implement a method where the subvi always runs but decides when to be visible, you'd probably need to get familiar with Queues or Notifiers as a method of asynchronous data communication.  A good thing to learn as you get more LabVIEW experience, but probably more difficult right now for the immediate problem at hand.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 6
(4,041 Views)