11-19-2014 11:59 AM
Hi,
I have written an application, it takes about 4 hours to run. Everything is fine with it, (it seems) but if you press the 'abort' button, then LabVIEW hangs and eventually crashes. I think that the longer the application runs before I hit abort the more likely it is to crash, but I could be imagining that bit. Are there some specific task that LabVIEW performs when abort is hit? Cleaning up the sessions, closing ports, etc... that the porgramming of my application may affect. If so, does anyone know how to track down the offending programming technique I am using?
Many thanks, Alec
(BTW, the I/O in this application is an RTU Modbus Device, a serial 232 device and a Compact DAQ chassis)
11-19-2014 12:08 PM
The abort button (the entire toolbar!) should not be visible in a properly built application.
11-19-2014 12:15 PM
e abort button, my friend, will not be visible in the final application. But that is not a solution to the problem. My problem indicates an error in programming technique, and it is this problem I am attempting to address.
11-19-2014 12:34 PM
There is probably nothing wrong with your program (at least regarding this specific issue ;)). Pressing abort while part of the code is executing inside a dll or communicating with an instrument etc. can give unpredictable results.
Maybe this old proverb can give you some ideas. 😄
11-19-2014 12:35 PM
All Heck can break loose when you hit that Abort button. Drivers, files, references, etc are not properly closed out. Execution is just randomly stopped. Memory isn't cleared. It is there for emergency purposes, which you are apparently running into. I have not had LabVIEW crash due to the abort button. But now that I'm thinking about it, it could be causing one of my coworkers to see a bunch of crashes.
11-19-2014 12:41 PM
From using the Abort your can't tell anything about the programming technique.
Use the Abort Execution button is like stopping your car with the help of a tree. The car will stop, it will not be pretty, and it will not tell you anything about the performance of the car. Maybe a little about the cars ability to handle crashes.
LabVIEW will not run any extra code after you hit that button, it will stop the run you are runing as fast as possible, without any cleanup. So if you are using some dll's, hardware or anything like that, you can't be sure what state they are left in.
For us to give you any feedback on your programming we need to details on the code.
The best way is the code itself, but sometimes that is not possible.
11-19-2014 06:20 PM - edited 11-19-2014 06:22 PM
let me try to be very clear,, when you press the abort button, LabVIEW attempts to stop the VI immediately it even try to release whatever resources were reserved while the VI was running sometimes it cannot do so.
Why? Something external to LabVIEW is maintaining the resources and LabVIEW is trying to play nice with those other external things. This explains the old proverb Christian was referring to. Unless you complete the VI normally unexpected things may happen but the VI will stop operating.
09-11-2017 09:27 AM
Hi, I am facing similar problem (only that LabView does not crash). I want to be able to clear any memory and close any handles as well as running VIs upon clicking the abort button.
It can be immensely helpful as I won't have the need to close LabView every time I do that.
In my case LabView opens sockets which remain open after I click on the abort button. so I would like that not to happen or at least be able to perform some kind of cleanup.
Is there an even that is fired/triggered when abort button is clicked? If there is one, it might be possible to capture that event in an external dll maybe and perform cleanup manually? Can LabView support/admins shed some light on it please?
Thanks
09-11-2017 09:36 AM
As the others said, 3 years ago, don't use the abort button to stop your program! Write your program to have a "stop" button that appropriately closed resources, etc. The abort is like hitting the power button on a computer, it stops the execution, but frequently with dire consequences. Look at the various architecture examples and pick one that will work best in your instance, then have a planned "Exit" state that closes all the references, sockets, etc. Abort won't do that.
09-11-2017 09:46 AM
What I do is use the Event Structure with a "Panel Close?" filter event. This way, when you try to close the window, this event will be called. Since it is a filter event, you can "discard" the closing and proceed to close everything out before letting your VI run to completion (ie all loops have completed and any additional code after said loops are done running). More commonly, people will have a stop button and use the Value Change event to stop their code in a similar manner.