06-24-2009 01:18 AM
Pnt a écrit:
JB wrote:Put this piece of code at the end of the main VI (the last operation just right before quitting the VI). Doing so, the EXE (App.Kind = Run Time System) will end without the need to manually close the FP of the main VI.
Yes but if you close the front panel manually, the application will be terminated normally when it has finished all actions, in all vis.
If you use that, you will force everything to close. It is like pulling the plug of your computer...
I do not like it
I use it only once in an application : at the end of the main VI. Therefore I really don't pull the computer's plug at any time ! All actions and all sub-VIs are already terminated or closed when calling the Quit LabVIEW function. The sole goal is to close the FP of the main VI automatically --> application closes without an additional user action. Would an example be helpful ?
06-24-2009 01:35 AM
Here is an example that shows the use of the Quit LabVIEW function. This would be the main VI of an application.
The "Do you want to use Quit LabVIEW ?" dialog is only there to allow you to "play" with the attached LV8.6.1 EXE.
06-24-2009 08:40 AM
JB-
How did you include an image without posting then editing your post?
Pnt-
The "Quit LabVIEW" primitive only shuts down the current application instance, so it is safe to run multiple EXEs simultaneously with this functionality.
Jorn-
Close.FP only closes the current front panel. So, if you had opened other panels open under the same application instance, "Quit LabVIEW" could be used to close all panels when your Main VI exits.
See attached for an example project with EXEs.
06-24-2009 08:48 AM
LabBEAN a écrit:JB-
How did you include an image without posting then editing your post?
Since the forum upgrade (May 20, 2009) it is no longer needed to edit the post to include a picture. So I didn't use any trick ! See here for more details.
06-24-2009 01:59 PM
One exe can have many front panels open. You can call them dynamiclly, or as simple sub vis.
Using the "Quit Labview" if you have many vis running is like pressing the stop button. Bad programming style.
If you normally close all your sub vis and you are at the end of your main vi (and you close the front panel), "Quit Labview" will do nothing. The exe will end, even if you don't put the "quit Labview". There is no difference.
This answers Jorn's question.
That is all... it is a function that can be handy in some cases, but no need to use it normally.
06-24-2009 03:47 PM
I am with pnt here.
My toplevel programs typically have no way to stop by themselves. Users are required to use the X in the upper corner to close the program. After all, that's how we close anything else running on a computer, nothing new to learn! 😉
(My programs don't interact with hardware, so no cleanup operations are needed. If cleanup operations are needed, we can trap the "panel close?" event and do some extra stuff. In this case, we might need the nugget, but I have not tried.)
06-24-2009 04:40 PM
I solved this problem in a different way; a looooonnnng time before App.Kind was available.
I have an article about it: The Terminator
As for never using the EXIT LABVIEW function - I don't know how you get around it.
It's not "brutal" - you only use it when you're ready to quit anyway.
And answering those tech support calls about why your window still hangs around after they quit gets old.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
06-24-2009 05:14 PM
altenbach wrote:
... Users are required to use the X in the upper corner to close the program. After all, that's how we close anything else running on a computer, ...
If someone prefers using the keyboard, he would press CTRL + Q ... or use the menu ... or a button on the front panel ...
If you just close the front panel of the main and don't pull the plug you have the chance to identify all SubVIs which are still running when the main VI should shut down.
A good programming style should finish all tasks properly, store results and so on. Then there is no need for Exit LabView, just close the front panel programmatically.
06-25-2009 01:17 AM
Closing all Front Panels will close the runtime engine as well.
Ton
06-25-2009 01:44 AM
Hi Christian,
How do you close your sub-VIs ? Also by the X in the upper corner ?
When building an application, I generally hide the title, scroll, tool and menu bars for the UI sub-VIs. Therefore there is no other way to close them except by a CLOSE button (nothing to do with the Quit LabVIEW function). Because I want to keep the same handling for the main VI, I have to call Quit LabVIEW (once the execution of the whole application is finished !) to close the last FP without any additionnal user action. The sole purpose of this function is to avoid the need to use the X in the upper corner. Nothing more, nothing less!
This can't be considered like a brutal abort of the application and I really don't see what's wrong about this technique...