LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running code after frontpanel close

Now that I think of it you probably could use an example of what I was talking about. in LV 8.2.1
0 Kudos
Message 11 of 14
(1,149 Views)

You can just hide the VI in the FP close event (Set FP.State to hidden). See image.

 

Hide-FP.png

 

Hope this helps,

Daniel

 

Message Edited by dan_u on 09-24-2009 06:01 PM
0 Kudos
Message 12 of 14
(1,140 Views)

The root cause of this issue is an intended behavior of the LabVIEW runtime engine.  If there are no VIs running and showing front panels, the engine exits.  This is what causes your application to exit prematurely.  You have several options, some of which have already been demonstrated.

  1. When you get the exit event, throw up a status dialog until your cleanup routine is finished, then exit.  This avoids the problem of the user not knowing what is going on.  Make sure your status dialog has some sort of animation so the user thinks something is happening.  It is better if the animation actually signifies progress, but not required.
  2. Minimize the window when you get the event, then exit when cleanup is finished.
  3. Move the window off the screen when you get the event, then exit when cleanup is finished.  To the user, this will be similar to 2, since the item will still exist on your task bar.
I prefer option 1, but option 2 or 3 are much easier.
0 Kudos
Message 13 of 14
(1,109 Views)

Well, the last panel in a built application that closes, kills the entire application instantly. No chance to run some code after that, you can not go over start, you can not get any money for going over start, etc. etc.

 

The way I solve this is using the Panel Close? Filter event and returning false to refuse that event. I then schedule the normal state machine close state and let that run, which will deallocate any resources it may find necessary, close files and other refnums, stores data, etc. After that and having given all other parallel tasks (loops) in the diagram a chance to close, I close the FP programmatically using a VI server method node.

 

That close state can also be caused by other sources such as a quit menu event, some button value changed events, etc.

 

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 14 of 14
(1,087 Views)