LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle a FP Close event?

Hi all,

 

I'm having the same issue as the one described here, that is to say that when the user clicks the X in the right top corner of a LV executable file, there is sill the icon in the taskbar:

http://forums.ni.com/t5/LabVIEW/executable-process-persist-after-X-closing-window/td-p/1803056/highl...

 

Therefore, I'm trying to implement the following code (posted in the link above) in my program:

 Close-1_BD.png

 

In the program, I want the user to be able to click on the X and quit the program at anytime he/she wants, and not only at the end. Therefore, I am not sure how to implement that or if it is even possible.

 

Does anybody has an idea?

 

Thanks

0 Kudos
Message 1 of 9
(3,483 Views)

With the diagram you have when the user clicks X at anytime it will quit the VI , not sure how you have integrated with the top level VI but this snippet will quit anytime X is pressed.

If this is not the case please elaborate on what behavior are you seeing?

*************************************************
CLD
*************************************************
0 Kudos
Message 2 of 9
(3,476 Views)

Thank you for looking at my case Ivrat.

 

If I underderstand correctly, the diagram will close the window only if the program is in the loop of the diagram at that time, right? I mean if the program is doing something completely different (like displaying data or save a file) at the other side of the program, nothing will happen.

 

If I add this piece of code to my program (at the end of it basically), when I click on the X at any time while the program is running, nothing at all happens. Should I post a VI file to make it clear?

0 Kudos
Message 3 of 9
(3,468 Views)

Yes, please post the VI.

You should never have several event structures, and if using only 1 your solution should work (although it's unnecessary, just wire the True to the stop loop). If you're in another event at the time, as a Save file-event, it's be queued up and processed afterwards.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(3,444 Views)

 

Hello,

 

This is some code I use a lot and I think it does the same as you need?

 

In this case I catch the panel close event in order to handle some stuff first (like saving final settings to a file, disconnect from services and such) and only when that is done I actually close the vi myself.

 

I made a small example code for it. I catch the panel close event and discard it. Then I do everything I need to do and the vi will normally enter the stopped state (white run arrow). Now I do a check to see if it is running in development mode or not (typically runtime). If it is running in development mode this is where I stop so it is possible to do some work on the diagram.

 

If it is running on a runtime system I will close the panel using a property node and all is gone.

 

 

 

close vi.PNG

---

25+ years long fan of LabVIEW. Move to Emerson looks to be for the better! See the last posts in subscription model thread.
0 Kudos
Message 5 of 9
(3,426 Views)

Thank you all for your answers.

 

My labview program is actually pretty big. I can make it simpler by removing/disabeling some parts, but the main idea is the program is made of a sequence. In the fourth step of the sequence, there is a gigantic while loop with the main core of the program. This loop includes many for and while loops. For now, I have put the FP handling in the last step of the top-level sequence. Therefore, when the program is in the gigantic while loop (or any of the sub-loops), clicking the X won't close the front panel until reaching the condition of the loop, right?

 

I actually have not posted the VI because while working on it, I realized that maybe I'm not thinking correctly the architecture of the program. Here is the situation:

- When the exe starts, the user has the choice between 2 buttons or to click on the X.

- If button #1 is clicked, the program executes an action and the user should be able to stop this action when he/she wants to come back to the initial state of the program

- If button #2 is clicked, the program executes an action and come back to the initial step of the program.

- If the X is cliked, the program quits. I would like this action to be work at any time while the program is running.

 

My first thought was to use the case structure in a while loop. It seems it is not the best choice from what you guys say.

Then I considered the event structure in a while loop. Seems a good idea, but when the program is running in the routine triggered by the button #1, if the user click the X, the program won't quit, right?

 

Please anybody correct me if I'm wrong because I'm not sure to fully understand how the event structures are working.

 

Thanks all.

0 Kudos
Message 6 of 9
(3,406 Views)

You want to handle all UI events in a separate loop with the event structure.  You can then send commands and status down to your other loop(s) using queues or notifiers.  So with a notifier, you could tell your button 1 routine to quit.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 9
(3,404 Views)

As a starting point you can take a look at Queued Message Handler template (browse from LabVIEW Launch window >>Create Project). Here is the image of default template with the properties added.See if this helps.

 

*************************************************
CLD
*************************************************
0 Kudos
Message 8 of 9
(3,381 Views)

@crossrulz wrote:

You want to handle all UI events in a separate loop with the event structure.  You can then send commands and status down to your other loop(s) using queues or notifiers.  So with a notifier, you could tell your button 1 routine to quit.


We also created a simple library for system events. We use this so that any code that is using the event structure can register with our system events and receive an Exit event which is generated by the UI or other section of code that is initiating the shutdown.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 9
(3,365 Views)