I am writing a program in which one thread needs to push elements into a queue, and one or more threads remove elements from the queue and process them. To avoid running out of memory, I would like the producer thread to sleep when the queue is full. Some elements have higher priority than others, so I would like them to be processed first. If the elements have the same priority, I would like the first to be added first for processing.
I want to display the 100 best elements or so in a WPF DataGrid, so the UI thread should also be facing it. It would be nice if he could notify the user interface thread that there is an update, i.e. Implements IObservable.
Is there a container class that will do all this?
For bonus points, I am sure that the entire queue should not be blocked both at the entrance to the queue and in the queue.
The .NET 4 implementations are fine.
mpen source
share