Re: A quick is this safe singleton question
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Fri, 2 Feb 2007 17:45:55 -0000
PokerMan <nospam@xxxxxxxxxxxxxx> wrote:
SO should i do this?:
static readonly myClass instance = new myClass ();
public static myClass Instance
{
get { return instance; }
}
myClass ()
{
_someObj = new SomeClass();
_someObj .Completed += OnComplete;
}
static myClass ()
{
}
Would that still call the code in my non static contructor?
Yes - the only difference is how "lazy" it will be. If you don't really
mind if the instance is constructed a bit early, or in some situations
where you don't end up needing it, you can do without the static
constructor.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- A quick is this safe singleton question
- From: PokerMan
- Re: A quick is this safe singleton question
- From: Hans Kesting
- Re: A quick is this safe singleton question
- From: PokerMan
- A quick is this safe singleton question
- Prev by Date: Re: SQL Parameter
- Next by Date: Re: How to handle a property?
- Previous by thread: Re: A quick is this safe singleton question
- Next by thread: Re: How to develop cad like application
- Index(es):
Relevant Pages
|