NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Active Participant
LarsUlrich
Posts: 268
0 Kudos
Accepted Solution

Funky producer/consumer behavior

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?

Active Participant
LarsUlrich
Posts: 268
0 Kudos

Re: Funky producer/consumer behavior

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.

Member
JonN
Posts: 27

Re: Funky producer/consumer behavior

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.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page