Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 15th, 2005, 02:29 PM
Ed S
Guest
 
Posts: n/a
Default 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

  #2  
Old November 15th, 2005, 02:29 PM
Alvin Bruney
Guest
 
Posts: n/a
Default Re: Critical Section?

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:eP69ac0nDHA.1672@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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
>[/color]


  #3  
Old November 15th, 2005, 02:29 PM
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: Critical Section?

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:eP69ac0nDHA.1672@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.