LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Application Close?" - Discard - Does this not work anymore?

Solved!
Go to solution

Hey, am I doing this wrong?  I wrote up a little Test VI because this doesn't seem to work the way I remember doing it in the past. (Although I don't remember that "Silent Shutdown" being an option).

 

Press the top right X - set Discard to True - and continue as normal (And more specifically - controlled) shutdown procedure.  LabVIEW 2020SP1

 

DailyDose_0-1684246696689.png

 

0 Kudos
Message 1 of 7
(1,192 Views)
Solution
Accepted by DailyDose

I've never used application instance close, rather <This VI> Panel Close?

 

Antoniooh_0-1684249961451.png

 

Message 2 of 7
(1,168 Views)

I'm guessing that, since you didn't handle (and discard) the Panel Close? event, that the panel still closes. Closing the panel will kill the whole program immediately, and the Event Structure won't be able to handle anything.

 

And I agree with Antoniooh- I think you should be using Panel Close, not Application Instance Close.

 

The Help is a little confusing: https://www.ni.com/docs/en-US/bundle/labview/page/lvprop/app_app_exitq.html

 

When not running in a Project, the Application Instance Close event fires when you use File -> Exit. If you use File -> Close then it triggers the Panel Close event.

 

If you want to handle clicking "X" at the top right, use Panel Close. If you want to handle File -> Exit, use Application Instance Close.

Message 3 of 7
(1,143 Views)

Ah - that's where the "SilentShutdown" came from.

Confession - I've always used "Panel Close" in the past... I just decided to brain fart this go around and never recover.
Thank you.

0 Kudos
Message 4 of 7
(1,114 Views)

If you aren't hiding your Menu bar, you should also handle Application Close in case the user clicks File -> Exit.

Message 5 of 7
(1,095 Views)

@BertMcMahan wrote:

If you aren't hiding your Menu bar, you should also handle Application Close in case the user clicks File -> Exit.


Application close is also alt+F4 and Windows shutdown, right?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(1,024 Views)

@Yamaeda wrote:

@BertMcMahan wrote:

If you aren't hiding your Menu bar, you should also handle Application Close in case the user clicks File -> Exit.


Application close is also alt+F4 and Windows shutdown, right?


Excellent question- I didn't know, so I made a quick test. I tried the following (including some obvious ones in case of future Googlers):

 

These are all from within the dev environment but NOT inside a Project:

1- Click the X: Panel Close

2- File -> Close: Panel Close

3- File -> Close All: Panel Close

4- File -> Exit: Application Instance Close

5- Alt+F4: Panel Close

6- Right click/Close Window on Taskbar icon: Panel Close

7- Ctrl+Alt+Del (Task Manager), click individual window for my test VI, End Task: Panel Close

8- Task Manager, right click LabVIEW Dev Environment, End Task: No event fired. LV just closed.

9- Clicked the X in the top right of the LabVIEW Project: Application Instance Closed. Setting Discard? to True prevented the Project window from closing.

 

One difference regarding the Task Manager when you're running the VI inside a Project:

1- Stopping the LV Project task from within Task Manager: Application Instance Closed fired, but everything shuts down regardless of whether you Discard the event or not.

 

And these again, from a compiled executable:

1- Click the X:Panel Close

2- File -> Close: Panel Close

3- File -> Close All: Panel Close

4- File -> Exit: Application Instance Close

5- Alt+F4: Panel Close

6- Right click/Close Window on Taskbar icon: Panel Close

7- Ctrl+Alt+Del (Task Manager), click individual window for my test VI, End Task: Fired the Panel Close event. I caught the event in an Event Handler and Discarded it, but the program still closed after a second or two. The Event Handler had a blocking popup saying which event was fired (Panel Close), and after displaying for a couple seconds the whole thing went away.

 

Tl;dr: The only time I could get an Application Instance Closed event to fire was when I closed the Project window and when I clicked File-> Exit. This is consistent with the Help file, though the Help file doesn't mention Ctrl+Alt+Del or Alt+F4. Those two both fire Panel Closed unless you're acting on a Project.

Message 7 of 7
(947 Views)