LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

windows -> taskbar RMB 'close window' question for executable

My labview executable has an event for when the user closes the window by pressing the X in the right corner, it closes all communcations nicely and shuts down.

However, when a performs the same action when the window is already minimized in the taskbar (right click and select 'close window') it behaves differently.

The app closes ultimately, but does not execute my 'panel close' event case. So it seems this is a different event? Thanks!

0 Kudos
Message 1 of 3
(2,097 Views)

The Panel Close event also executes when using your "taskbar RMB" on a minimised FP unless you are doing something in your application to suppress this event.
Closing applications properly has been discussed several times (e.g. here) and I also prefer the usage of the "Panel Close?" filter event.

0 Kudos
Message 2 of 3
(2,073 Views)

I think the reason for this is that the Application Close event is really sent after LabVIEW has done everything internally to exit. As one of the last things it sends the Application Close event to all registered event structures and then effectively quits. If you trigger that event from the upper right corner in a front panel, there is still the panel window that needs to be closed and what else, which leaves your VI a small timewindow to execute some code, before the panel effectively is closed. Once the panel is closed the LabVIEW VI ceases to exist immediately, since there is no other VI refnum that keeps it alive.

 

When the window is already minimized, this timewindow gets a lot smaller and your code you execute in the Application Close event frame has almost no chance to do anything useful. But using the Application Close? filter event instead as GuenterMueller already states, will solve that problem, since now the event is called before LabVIEW takes any action to really close the application. You can refuse the exit in the filter event, but that is something that should only be done diligently. Even if you just postbone it a little, by passing that event to a different part of your application such as a state machine and eventually exit programmatically by terminating the main loop, this already adds a potential debug hassle, since if there is any bug in this part of the code that prevents the main loop from stopping, you effectively locked out Exit for yourself and only the Kill Process option in the Task Manager will help out of this.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(2,032 Views)