473,226 Members | 1,581 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,226 software developers and data experts.

Critical Section?

HiAll,

What would you suggest I use if I want to protect the creation of a
singleton - in the instance() static method. In C++, I'd use a critical
section.

Thanks,

--Ed

Nov 15 '05 #1
2 19692
say
lock(this)
{
create singleton here
}

Locking on this is bad though because some other thread could conceivably
lock on this creating a deadlock of sorts. But that will give you roughly
the equivalent of a critical section.
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Ed S" <esinek.mapson-a-t-mapson.summation.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
HiAll,

What would you suggest I use if I want to protect the creation of a
singleton - in the instance() static method. In C++, I'd use a critical
section.

Thanks,

--Ed

Nov 15 '05 #2
Ed,
Here is a write up on how to write a Singleton in C#, complete with making
it thread safe.

http://www.yoda.arachsys.com/csharp/singleton.html

Hope this helps
Jay

"Ed S" <esinek.mapson-a-t-mapson.summation.com> wrote in message
news:eP**************@TK2MSFTNGP09.phx.gbl...
HiAll,

What would you suggest I use if I want to protect the creation of a
singleton - in the instance() static method. In C++, I'd use a critical
section.

Thanks,

--Ed

Nov 15 '05 #3

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

Similar topics

2
by: Brian Alexander | last post by:
Hello; I am trying to protect some global data, which may, in the future, be accessed by threads. I'm not sure how to implement a locking mechanism in python. Here is the idea I'm trying to...
1
by: asimeerza | last post by:
hi all i m developing web applicaiotn with vb+asp dot net. i ve many links at my page and i m also maintaining session. if the user of my applicaton clicks one link that sends request to the...
2
by: Xarky | last post by:
Hi, I am trying to learn Critical Sections. I have written a small program. Source code problem below. What the program is doing is disabling the CRTL-C signal in the critical section. My...
7
by: Piotrek Stachowicz | last post by:
Hi, I need to create the situation in my system, where no more critical sections can be initialized (win2000Server). I thought about creating a simple c# application and using the Monitor class....
6
by: MPH Computers | last post by:
Hi I am looking for some help on Threading and Critical Sections I have a main thread that controls an event the event handler creates a new thread for carrying out the work because the...
2
by: Christian | last post by:
I have a class named AccessClass to access a legacy system. In a webform i instanciate an AccessClass object named myAccess and i call a method : myAccess.accessmethod() I want to insure that no...
1
by: James Hunter Ross | last post by:
Friends, this is a longshot... Our app is done in ASP.NET/C# with calls to legacy DLLs that use MFC/ODBC to update the database. It's a legacy DB API that we must use. We're debugging an...
3
by: Harry Whitehouse | last post by:
Hi! I've been migrating some legacy ISAPI appliations to .NET Webservice. In one, I call a third party routine which is not thread safe. In the ISAPI world, I put a critical section around the...
5
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi, I have a component where I need to have thread-safe access to a list. Operations on the list are done in critical sections (lock (lockObject) { ... } ) in the usual way, to make sure that no...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.