11-26-2012 05:16 PM
Hi All, I have a big program including a lot of things. When I converted it to an exe file, it cannot be closed properly. I used to load the dynamic vi in this program and cannot close it by clicking "X" of the window. Now I have removed that dynamic load but still cannot close the exe. Could anyone give me some advice? Thank you!
11-27-2012 12:45 AM
Assuming your program closes OK in the development environment, the first item may not be your problem but just in case ...
1) Each looping structure must have an exit strategy (i.e. "a way to terminate") when you close the program
Make sure that all your loops are completing.
2) Vis with event structures tend to need some help to close their front panels
I use the following code:
The other case is Development System (empty).
Not required, but using the "App.kind" property node like this prevents the vi from closing in the development environment.
steve
11-27-2012 12:45 AM
Hello
it is difficult to predict the reasons, with the limited information. show us some pictures of how the executable stays when you close it.
for now, questions:
how are you closing the EXE? Panel close (X) on the top right corner/stop or exit button on the GUI? Or are you using a FP Close invoke node?
how are you handling the event for Panel close or for Stop/exit button?
how many loops are running in parallel inside the EXE? how are you stopping those loops when the panel is closed or a Stop/Exit button is pressed.
have you checked if all the loops are closing when you stop the EXE?
does this work well when you run the source code? have you checked for any errors when yuo stop your EXE?
when you say it cannot be closed properly, there could be two things:
1. the front panel/GUI does not close and it stays there. you cannot perform any GUI actions, or it seems to have hung.
2. the GUI closes but you can still it in the task bar below, you will have to use the Task manager to force close the executable.
which of the above points are relevant?
11-27-2012 02:17 PM
Hi Freelance_LV, thank you for your advise, here is a program for a USB dongle. Here are the answers:
for now, questions:
1. how are you closing the EXE? Panel close (X) on the top right corner/stop or exit button on the GUI?
[A] I use (X) on the top right corner but it did not work. But when I use exit button on the GUI it worked.
2. Or are you using a FP Close invoke node?
[A] No
3.how are you handling the event for Panel close or for Stop/exit button?
[A] events are inside a sequence frame
how many loops are running in parallel inside the EXE?
[A] It is hard to tell. I am not the original creator of this code, but the main structure is this: a big "for" loop, inside there are some sequence frame, and some events in one of the frame.
how are you stopping those loops when the panel is closed or a Stop/Exit button is pressed.
[A] the main loop inlcudes some events, sequence frame, and something like this. And there is a subvi from some previous people's work to close USB.
have you checked if all the loops are closing when you stop the EXE?
[A] Sorry I don't know how to check all the loops are closed.
does this work well when you run the source code?
[A] yes source code can be always be closed well.
have you checked for any errors when yuo stop your EXE?
[A] sorry I don't know how to check for errors?
when you say it cannot be closed properly, there could be two things:
1. the front panel/GUI does not close and it stays there. you cannot perform any GUI actions, or it seems to have hung.
[A] Yes GUI still there. But cannot perform any GUI actions.
2. the GUI closes but you can still it in the task bar below, you will have to use the Task manager to force close the executable.
[A] Not this case.
Thank you very much!
11-27-2012 03:44 PM
Hi Steve, is the picture you post your complete solution to close the GUI? If not, could you share with me this specific part of code? Thank you!
11-27-2012 04:43 PM
@bhl3302 wrote:
Hi @Freelance_LV, thank you for your advise, here is a program for a USB dongle. Here are the answers:
for now, questions:
1. how are you closing the EXE? Panel close (X) on the top right corner/stop or exit button on the GUI?
[A] I use (X) on the top right corner but it did not work. But when I use exit button on the GUI it worked.
Use the "Panel Close?" event. (not "Panel Close")
Wire True to the Discard? option.
Copy the code being executed when hitting the GUI stop button.
- I usually do this outside my main while loop.
- Another option might be to use a value change (signaling) property node on the GUI stop button. This does not work on momentary/single pulse buttons.
Adam
11-27-2012 05:01 PM
Hi Adam,
If I just want to use the "X" on right top side of the window of exe file to close the program, could you tell me how? Thank you very much!
11-27-2012 05:13 PM
Hi Steve, I am trying to use your solution but got the problem in connecting this block to event case. Here is the snapshot. Could you take a look? Thank you!
11-27-2012 11:10 PM
in how many directions is your data flowing!!
please post the full VI. we cannot help much with the image you uploaded.
also, if you want to use the X button on the top rigth corner of the window, then add an Event case to the event structure for Panel Close event. if you post your code, we can tell you in more detail, what can be done
11-28-2012 08:21 AM
Assuming you already have an event structure for GUI inputs....
1. Create a new event: <This VI> -> Panel Close?
2. Wire a true to Discard?
3. *Execute the code that is being run on a GUI Stop button command.*
4. Use (This VI) invoke node Front Panel.Close to close the vi after execution completes.
If you don't mind your VI running in the background until it finishes closing up shop, you can skip steps 2 and 4.
Without seeing your code, it will be difficult to give you more help other than these generalizations.