<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Running code after frontpanel close in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990419#M443201</link>
    <description>Forgot to attach the files</description>
    <pubDate>Thu, 24 Sep 2009 09:03:12 GMT</pubDate>
    <dc:creator>tfritz</dc:creator>
    <dc:date>2009-09-24T09:03:12Z</dc:date>
    <item>
      <title>Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990417#M443200</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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). &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tobias &lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 09:02:26 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990417#M443200</guid>
      <dc:creator>tfritz</dc:creator>
      <dc:date>2009-09-24T09:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990419#M443201</link>
      <description>Forgot to attach the files</description>
      <pubDate>Thu, 24 Sep 2009 09:03:12 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990419#M443201</guid>
      <dc:creator>tfritz</dc:creator>
      <dc:date>2009-09-24T09:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990501#M443238</link>
      <description>&lt;P&gt;Hi tfritz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this. &lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by gak on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt; 09-24-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 06:13 AM&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Sep 2009 11:13:41 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990501#M443238</guid>
      <dc:creator>Gak</dc:creator>
      <dc:date>2009-09-24T11:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990503#M443240</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks. Could you save this in Labview 8.2? I cannot open it. Sorry that I didn't state my version! &lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 11:19:10 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990503#M443240</guid>
      <dc:creator>tfritz</dc:creator>
      <dc:date>2009-09-24T11:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990508#M443242</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actually if it *would* work, I wouldn't understand it, as it wouldn't make any sense in my opinion...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks anyway,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tobias &lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 11:23:16 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990508#M443242</guid>
      <dc:creator>tfritz</dc:creator>
      <dc:date>2009-09-24T11:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990509#M443243</link>
      <description>Here it is. It does not show all pop up messages. But definitely closes FP before message is displayed.I think that is what you wanted.</description>
      <pubDate>Thu, 24 Sep 2009 11:24:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990509#M443243</guid>
      <dc:creator>Gak</dc:creator>
      <dc:date>2009-09-24T11:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990510#M443244</link>
      <description>&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;It can be done using one dialog box only. &lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 11:30:50 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990510#M443244</guid>
      <dc:creator>Gak</dc:creator>
      <dc:date>2009-09-24T11:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990520#M443247</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tobias &lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 11:53:48 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990520#M443247</guid>
      <dc:creator>tfritz</dc:creator>
      <dc:date>2009-09-24T11:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990526#M443248</link>
      <description>I dont know how to do it...but if you just want to execute some code after panel close event, then you can use minimize method first in event case, then your code will execute and then you can close your VI. I hope i have cleared what i want to say.</description>
      <pubDate>Thu, 24 Sep 2009 12:06:42 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990526#M443248</guid>
      <dc:creator>Gak</dc:creator>
      <dc:date>2009-09-24T12:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990658#M443297</link>
      <description>&lt;P&gt;I guess I don't understand why you want to continue to execute code after the front panel is closed? gak has a good&amp;nbsp;simple solution&amp;nbsp;to minimize first then close when done. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&amp;nbsp;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.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2009 14:51:48 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990658#M443297</guid>
      <dc:creator>Rob_F1</dc:creator>
      <dc:date>2009-09-24T14:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990720#M443322</link>
      <description>Now that I think of it you probably could use an example of what I was talking about. in LV 8.2.1</description>
      <pubDate>Thu, 24 Sep 2009 15:28:26 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990720#M443322</guid>
      <dc:creator>Rob_F1</dc:creator>
      <dc:date>2009-09-24T15:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990746#M443335</link>
      <description>&lt;P&gt;You can just hide the VI in the FP close event (Set FP.State to hidden). See image.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://ip1.i.lithium.com/5101fdaef2e6223c5c6fb0fe5ae98b22245adba1/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f3438323269304436393830383943453042354243352f696d6167652d73697a652f6f726967696e616c3f763d6d70626c2d312670783d2d31" border="0" alt="Hide-FP.png" title="Hide-FP.png" align="CENTER" /&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by dan_u on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt; 09-24-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 06:01 PM&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Sep 2009 16:01:37 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/990746#M443335</guid>
      <dc:creator>dan_u</dc:creator>
      <dc:date>2009-09-24T16:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/991346#M443522</link>
      <description>&lt;P&gt;The root cause of this issue is an intended behavior of the LabVIEW runtime engine.&amp;nbsp; If there are no VIs running and showing front panels, the engine exits.&amp;nbsp; This is what causes your application to exit prematurely.&amp;nbsp; You have several options, some of which have already been demonstrated.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When you get the exit event, throw up a status dialog until your cleanup routine is finished, then exit.&amp;nbsp; This avoids the problem of the user not knowing what is going on.&amp;nbsp; Make sure your status dialog has some sort of animation so the user thinks something is happening.&amp;nbsp; It is better if the animation actually signifies progress, but not required. &lt;/LI&gt;&lt;LI&gt;Minimize the window when you get the event, then exit when cleanup is finished.&lt;/LI&gt;&lt;LI&gt;Move the window off the screen when you get the event, then exit when cleanup is finished.&amp;nbsp; To the user, this will be similar to 2, since the item will still exist on your task bar. &lt;/LI&gt;&lt;/OL&gt;I prefer option 1, but option 2 or 3 are much easier.</description>
      <pubDate>Fri, 25 Sep 2009 12:38:11 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/991346#M443522</guid>
      <dc:creator>DFGray</dc:creator>
      <dc:date>2009-09-25T12:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Running code after frontpanel close</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/991945#M443786</link>
      <description>&lt;P&gt;Well, the last panel in a built application that closes, kills the entire application instantly. No chance to run some code after that, you can not go over start, you can not get any money for going over start, etc. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The way I solve this is using the Panel Close? Filter event and returning false to refuse that event. I then schedule the normal state machine close state and let that run, which will deallocate any resources it may find necessary, close files and other refnums, stores data, etc. After that and having given all other parallel tasks (loops) in the diagram a chance to close, I close the FP programmatically using a VI server method node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That close state can also be caused by other sources such as a quit menu event, some button value changed events, etc. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rolf Kalbermatter &lt;/P&gt;</description>
      <pubDate>Sat, 26 Sep 2009 19:46:27 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Running-code-after-frontpanel-close/m-p/991945#M443786</guid>
      <dc:creator>rolfk</dc:creator>
      <dc:date>2009-09-26T19:46:27Z</dc:date>
    </item>
  </channel>
</rss>

