I have a Windows Form application that has a static Queue collection. At some point, i kick off 1 Thread and dequeue the Queue in it.
My problem is that it doesn't properly dequeue after the first myQueue.Dequeue (). So if I only had one object in that queue, the loop would iterate twice. Why does it do that? Does it have something to do with the fact that I am dequeueing in another thread?
Code:
//inside Thread
while (myQueue.Count > 0)
{
obj = myQueue.Dequeue();
//process obj
}
Comment