06-07-2016 01:00 PM
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?
Solved! Go to Solution.
06-07-2016 01:08 PM
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).
06-07-2016 01:50 PM
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.
06-07-2016 01:51 PM
Thank you! I looked up error handling and got it working.