473,408 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Semaphore support?

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/Bo...ckingQueue.asp and
http://www.codeproject.com/csharp/Di...gSemaphore.asp, which will
work if necessary, but I'm more interested in native framework support if
possible.

Thanks.
Nov 16 '05 #1
2 3468
dln <dn**********@hotmail.com> wrote:
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/Bo...ckingQueue.asp and
http://www.codeproject.com/csharp/Di...gSemaphore.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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"dln" <dn**********@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
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/Bo...ckingQueue.asp and
http://www.codeproject.com/csharp/Di...gSemaphore.asp, which will
work if necessary, but I'm more interested in native framework support if
possible.

Thanks.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bastian Hammer | last post by:
Hi I´m wondering why there are so few examples with Semaphore. Is it obsolete? I´ve got a Class Data. It offers 2 Threads methods for updating, editing, .. a private dictionary. Now I...
1
by: rushik | last post by:
Hello all, I m facing an interesting problem related to semaphore in php. We are using a huge business application running on LAMP. For database operations we are maintaining centralized DB...
5
by: marvind | last post by:
I tried using a Semaphore class (have included the full listing reproduced from article Figure 1 at the end of this email) in .NET 1.1. It works fine most of the time, however, I see the following...
5
by: Unni | last post by:
Hello all, I m facing a memory related problem with semaphores. Our business application uses semaphores extensively and the limit imposed by the OS on the number of semaphores that can exist on...
2
by: techi_C | last post by:
Hi I'm getting a problem while removing semaphore from system. Before removing semaphore I'm checking the usage count of a smaphore. // checking usage count usage_count =...
1
by: cranfic | last post by:
Please help... To make it simple, I have a simple test C program which calls my semphore library functions only. (It doesn't call any db2 function at all). And the following is the test...
0
by: Samuel R. Neff | last post by:
I'm having trouble creating a Semaphore with read-access rights for everyone. Originally I was trying to use this code: semaphore = new Semaphore(maxLocks, maxLocks, "RwLock#" + name); but...
5
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt !=...
0
by: Christian Heimes | last post by:
Neal Becker wrote: No, it just provides unshared semaphores. You can either create your own Python extensions or you can use ctypes if you need a shared or named semaphore. Depending on your...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.