Semaphore support?

  • Thread starter Thread starter dln
  • Start date Start date
D

dln

I can't seem to find a Semaphore class in the .Net framework. Does C#
provide any blocking container objects that will block a thread trying to
extract an element from an empty queue or does the .Net framework provide a
Semaphore object of some type? I've noticed a post to the urls
http://www.codeproject.com/csharp/BoundedBlockingQueue.asp and
http://www.codeproject.com/csharp/DijkstraCountingSemaphore.asp, which will
work if necessary, but I'm more interested in native framework support if
possible.

Thanks.
 
dln said:
I can't seem to find a Semaphore class in the .Net framework. Does C#
provide any blocking container objects that will block a thread trying to
extract an element from an empty queue or does the .Net framework provide a
Semaphore object of some type? I've noticed a post to the urls
http://www.codeproject.com/csharp/BoundedBlockingQueue.asp and
http://www.codeproject.com/csharp/DijkstraCountingSemaphore.asp, which will
work if necessary, but I'm more interested in native framework support if
possible.

No, there's no native framework support in 1.0/1.1, although there will
be in 2.0.
 
dln,

In .NET 1.1, there is no Semaphore class. You would have to call the
CreateSemaphore API function (through the P/Invoke layer) and work with
that.

In .NET 2.0, there is a Semaphore class that you can use which gives you
the semantics that you want.

Hope this helps.
 
Back
Top