05-10-2012 01:09 PM
So this is a weird one...
I've got a producer/consumer loop taken (mostly) from the template labview builds.
For some reason, when I click the stop button, instead of stopping the program, it wants to run through the default case (shown in image) a second time. I.e. I run the program, que my event, the event runs through, I click the stop button, then the event runs though again and finally stops.
Also, there are 2 times in my program where I save data, in the beginning where I set up the headers, and after all the data is taken. If I abort the program after clicking the stop button, but before the event runs through again (there is that while loop that idles until I click "accept level") if I abort the execution then, the data of the previous run is not saved. (Though the 1st write to spreadsheet.vi may be overwriting the previous run's data, which could be why it is missing).
What did I do wrong that makes my program execute twice?
Solved! Go to Solution.
05-10-2012 01:25 PM
On second inspection, it looks like if I give the stop case an enque element, and make an empty case in the consumer loop that it triggers, I may be able to avoid running through the routine a duplicate time before stopping the program.
05-10-2012 01:36 PM
If you're relying on the destruction of the queue reference to stop the bottom loop, wrap the bottom case structure with another case structure that branches on the Dequeue Elements error out -- use existing case in the non-error condition and any special processing within the error/shutdown case.