views:

36

answers:

1

I know about the Semaphore class in the System.Threading namespace, but I don't see if it allows waiting threads to have different priorities levels.

If two threads are waiting for an open slot, is there a way to allow the thread with the higher priority to have the first open slot available?

+1  A: 

From the MSDN documentantion on the Semaphore class

There is no guaranteed order, such as FIFO or LIFO, in which blocked threads enter the semaphore.

But take a look at these two projects which both supports priority for threads.

Smart Thread Pool

Thread-safe priority queue in C#

Mikael Svenson