I have a C# Windows service which has been running in my production environment for years.
The service has several ConcurrentQueue instances. One of these queues (queue "A") receives Enqueues from three different "producers", each one within a different thread.
A fourth thread does the Dequeuing.
I’ve made some seemingly unrelated code changes, and am perplexed by what I'm now observing: Queue "A" only correctly processes traffic from two of the three producers.
While debugging, I stopped the Enqueues from the two "working" producers, and observed the following with the "problem producer":
1. When I step through the Enqueue statement, everything looks fine: That is, the Queue.Count correctly increments, Queue.IsEmpty == false, and my data is correctly residing in a queue element.
2. However, when the fourth thread calls TryDequeue on the same queue, nothing is found. Also, Queue.IsEmpty == true, and Queue.Count == 0.
3. Repeated Enqueues cause the Queue.Count to keep increasing and my new items accumulating, as shown by the debugger.
Has anyone ever encountered this type of behavior?
Thanks in advance,