LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I properly handle application closure?

Hi all, I've got a couple VI's running inside a main VI. One of them is user input, and the other is a controller. The user input VI runs first, and has a cancel button. This button should stop both the user input VI and the controller VI. After the user input VI completes, the controller VI is run. When the stop button on the controller's front panel is pressed, the controller and main VI should stop.

 

I don't think using "Exit Labview" is a good practice here. I do think the "Stop" literal will come in handy, but I don't really understand how dataflow works once a VI is forced to stop.

0 Kudos
Message 1 of 2
(2,439 Views)

ijustlovemath wrote:

I don't think using "Exit Labview" is a good practice here. I do think the "Stop" literal will come in handy, but I don't really understand how dataflow works once a VI is forced to stop.


Both the Exit LabVIEW and the Stop primitives ABORT your VIs.  This is the same as pressing the Abort button in the toolbar.  And who knows what you have left open and leaks could happen from that.

 

What you want to happen is for the VIs to stop normally (all loops are stopped, no more code left running).  based on what I can tell from your description, I would probably just use a User Event or a global variable to tell all of the loops to stop.  The User Event is good for telling your GUI loops to stop (works with the Event Structure) and the global variable is good for stopping free running loops.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 2
(2,426 Views)