09-24-2009 04:02 AM
Hi,
I have a problem with executing code after a panel close event. I want to make an application out of my Labview Project and I feel that it is the natural way for Applications to exit them by clicking the close button of the window. I handled the "Frontpanel close" event in an event structure. However, I have to execute more code, specifically in a parallel loop to exit the application gracefully. This always caused crashes I didn't understand. I tried to find out what is happening there and after a while I found out that apparently code after a front panel close isn't executed anymore.
I found out that I can avoid this by supressing the panel close event, correctly finish the VI and then close the front panel programatically. This works but looks really strange (If I press the close button in the application, it takes another 1-2 seconds, until the window closes because of the code that is executing).
To demonstrate what I mean, please see the two attached VIs. Maybe you'll have to convert them to your version of LabView first to really see what I mean (because if there is a dialog after closing the VI, the effect won't occur).
test.vi will only show the first message box if you close the front panel, but not the second. test2.vi works around this by supressing the close event and close the front panel later programatically.
My question is: is there really no other way to do this? I'd like the front panel to close immediately when I press the close button but want the rest of the code in the VI to finish nevertheless.
Thanks a lot,
Tobias
09-24-2009 04:03 AM
09-24-2009 06:13 AM - edited 09-24-2009 06:13 AM
Hi tfritz,
Try this.
09-24-2009 06:19 AM
Hi,
thanks. Could you save this in Labview 8.2? I cannot open it. Sorry that I didn't state my version!
09-24-2009 06:23 AM
Hi,
nevermind, I opened it on a PC that already has 8.6 installed. However, it doesn't work, either, i.e. the second message box doesn't appear. Did it for you?
Actually if it *would* work, I wouldn't understand it, as it wouldn't make any sense in my opinion...
Thanks anyway,
Tobias
09-24-2009 06:24 AM
09-24-2009 06:30 AM
Or what you can do is, place both "One button dialog" functions in the same event. But I do not understand why do you want to display message using 2 dialog boxes?
It can be done using one dialog box only.
09-24-2009 06:53 AM
Hi,
no, this is not what I wanted. The point is that my application needs to still execute code after the frontpanel has been closed. With my two VIs I just wanted to show that this doesn't seem to work correctly. test.vi doesn't display the second Message Box, even though it should (because I'd expect the VI code to finish executing even if the frontpanel was closed). However, this doesn't work, so I have to supress the close event, execute the code and close the panel manually in the end. I wondered if this is by design and if yes, why.
Tobias
09-24-2009 07:06 AM
09-24-2009 09:51 AM
I guess I don't understand why you want to continue to execute code after the front panel is closed? gak has a good simple solution to minimize first then close when done.
If you absolutely need to run code without a front panel then you will need two vi's. One that executes the code in a hidden state and a user interface. Build the user interface to call the functional vi dynamically and set the property to run hidden, that way it will run unseen in the background. If you need to transfer any data do it using the Queues. After you close your user interface the hidden code can continue to execute until it is finished.