LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Application Close Process

Hi There,

 

I would like to run some code when the VI/application closes, regardless of the method used to close. I have a handle provided by a DLL call, and I want to make sure that I call the function to close the handle and free up the resources when my app closes. It seems to me that I would want to catch the "Application Instance Close" event to make sure this is executed every time the app shuts down. I have tried to test a simple version of this to confirm it is working - and it isn't. The attached picture shows my simple while loop with a stop button that has the event handler structure inside. I haven't been able to confirm that the Application Instance Close event code has been executing, mainly because my while loop doesn't seem to be responsing to the stop button. I am guessing that execution is maybe stalled by the event handler waiting for something???

 

Any ideas or pointers?

 

Thank you.

 

Brian

0 Kudos
Message 1 of 3
(2,183 Views)

Try to add timeout to the event structure. The value of your stop button is read only once when the loop starts and after that the loop stops to wait for the event. When you add a timeout of, for example 100 ms, the value of stop button is read once every 100 ms

0 Kudos
Message 2 of 3
(2,170 Views)

That seems to have worked as far as being able to read the stop button. You also have to add a Timeout event handler to make Labview happy, but I just left mine empty. So does this mean that every time the while loop executes it will wait XXmS for an event and then process the rest of the code in the loop? That could be either very irritating, or an interesting way to control a timed interval for code execution.

 

But now that I am able to use the stop button, it looks like my shutdown code isn't executing. I have some a message box pop up just for debugging to let me know that this section of code executes, and I never see it. I even tried duplicating the same code in the Panel Close? event handler. I also tried highlighting execution, and it does not seem to drop in to the event handler. I am still stumped about how to get some clean up code to run when the application closes. Is there something else I am missing?

 

Brian

0 Kudos
Message 3 of 3
(2,154 Views)