05-07-2014 07:56 AM
05-20-2014 05:43 PM
Do I understand how the Application instance close? filter event with discard true works? Does it trap the red X close and not do anything beyond letting me know that the red X has been clicked so that the cleanup can be run before shutting down?
It seems to be working differently on this system (labview 2013 running on Ni PXIe8135 controller and windows 7). There are no dynamic vi's. There is a dialog in in the Application instance close? event and one in my cleanup routine to show what was going on. When I click the Red X, the front panel vanishes but the process is still running. No dialogs are displayed. When I kill the program with task manager the dialogs are displayed. Do you know what is happening here?
Thanks, Jeff, for the post. It was very helpful.
I did find an alternate solution. Instead of using Application instance close? use <This vi> panel close? This allows the cleanup to run and the program is no longer running.
05-20-2014 05:55 PM
Yes! Clicking on the red X in the upper right corner does not trigger an application close event but simply a front panel close event, first the filter event and then the final event. Once the front panel is gone and no other references are open to the VI, the VI is unloaded and when this was the last front panel loaded, the LabVIEW application exits. So you have really two event cases of quiting a LabVIEW app:
1) panel close event (?) on the last (usually main) VI panel
2) application close event when the system tells LabVIEW to please quit
I usually solve this by having a state machine wrapped around the event structure. Any of the quit events such as a menu selection, front panel close, application close and explicit quit buttons eventually goes through the exit state in which everything is completely cleaned up, then the state machine is exited and the panel is explicitedly closed through VI server again just to be sure (for the menu, app close event and exit buttons). This is the last action that the main VI does and after that the LabVIEW runtime engine quits automatically for sure.