Getting a "Queue is empty" exception when Queue.Count > 0
Hi all,
I have the following simple code in my not-so-simple application:
while
(frameQueue.Count > 0){
if (boolRunning){
ProcessFrame(frameQueue.Dequeue());
...
...
From time to time, the Dequeue method throws an exception saying that the "Queue is empty".
Now, the application is multi-threaded, but dequeuing only occurs at this point, so it doesn't "make sense" (please forgive me for using this term) that the queue was cleared between the Count property test and the call to Dequeue.
Moreover, when the exception is thrown, the value of Count is always >0. Since another thread enqueues the frames, that doesn't say too much, but I wonder if there's any known issue with the Queue collection.
Any help will be greatly appreciated.
Thanks,
Ury

