LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Release notifier outside of consumer loop

Solved!
Go to solution

Hi all,

 

I am using a notifier for a stop button.  My stop button wasn't stopping in one of the  cases(Error 1 occurred at Wait on Notification in Main MTTF.vi).  I highlighted the code and noticed that when I pressed stop, the notifier was being released before notifying the consumer loop.  When I released the notifier outside the consumer loop, my error was gone.  

 

It seems like a simple fix which is great, but ine everything I have read or seen so far, the release was outside the producer loop.  Is there any disadvantage to doing it this way?

0 Kudos
Message 1 of 4
(2,995 Views)
Solution
Accepted by topic author _natalie_

A more common way to handle this is to treat an error from Wait on Notification as a stop condition, because the error indicates that the notifier was released, and the only way that could happen is that the producer loop exited.

 

The way you've described it, you could get into a situation where the producer loop stops but the consumer does not, and since the notifier isn't released until the consumer exits, the consumer loop will never stop because it's waiting forever for a notification that will never come (but the notifier is still valid, so it continues to wait).

0 Kudos
Message 2 of 4
(2,992 Views)

Typically with a Producer/Consumer architecture, you are using a queue.  So I tend to put my stop commands into the queue.  Then the consumer can do all of the cleanup for itself.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(2,984 Views)

Thank you!  I looked up error handling and got it working.  

0 Kudos
Message 4 of 4
(2,980 Views)