LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Learning to use queues producer consumer event

Solved!
Go to solution

tbob, thanks for that explanation. It was very helpful. My only concern is if I create a program that has many non-queue events in the event structure. Then the terminated queue won't have the ability to shut down the producer. Since the program will still be running, a user may ignore the consumer error and keep making changes to the program. The program won't stop until a queue element is accessed. I also don't really like the idea of having to poll or access a queue in an event that really doesn't have a need for one (just to check for an error).

 

Oh, and could you please post the vi for version 8.5 or lower Smiley Happy. Much appreciated!

0 Kudos
Message 11 of 13
(703 Views)
Solution
Accepted by topic author Newbie217

I don't have 8.5 so I can't save it to that version.  I have included a png to show what I did.  I moved the error dialog from the Exit case to the Error case after the producer loop, and added a new error case after the consumer loop.

 

To notify the producer loop if an error has occured in the consumer loop, you would have to add a queue function to each and every event case.  For cases when no queueing to the consumer is needed, you could use the Get Queue Status function or the Preview Queue function.  Neither of these would upset the queue during normal operation, but they would allow for an error detection.  Very little overhead and it gets the job done.  Otherwise you would have to use some local variable to signal the producer to stop.

 

Program1[1].png

 

- tbob

Inventor of the WORM Global
Message 12 of 13
(693 Views)
Looks good. I'm going to go with the 'Get Queue Status' approach to feedback the error into the other events. That should do the trick for now Smiley Wink
0 Kudos
Message 13 of 13
(680 Views)