C# TPL Priority Queue
I needed a way to post work items into a queue and have them processed one at a time, yet have the ability to post high priority items and get them done first.
I've use a simple implementation of PriorityQueue to store the work items.
I've use TPL Task to handle the execution and continouation and thus eliminating the need for hard-to-test multi-threading code.
int handledItems = 0;
var subject = new PriorityTaskQueue<string>(
item => handledItems++);
for (int i = 0; i < 10; i++) {
subject.Post("A" + i, 0);
}
This project is under MIT license.
PriorityTaskQueue is currently designed to process one item at a time.