I have a scenario where
-
multiple threads are pushing data on a Queue
-
only ONE thread is processing data using code below
code –
while ( Continue )
{
while ( queue.Count > 0 )
{
MyObj o = queue.Dequeue();
someProcess(o);
}
myAutoResetEvent.WaitOne();
}
But sometimes, queue.Dequeue() returns null in the scenario above
What gives ?
You need to read this blog post.
Also, here’s a very minimal skeleton of a “channel” for communication between threads: