G
Guest
Hi all,
I'm quite new to C#.
I am trying to implement some basics reusable classes using this language
and the .NET Framework technology.
What I'm trying to do now is to implement a singleton class.
I did have a look at the Microsoft "Patterns and Practices" article
"Implementing Singleton in C#"
(http://msdn.microsoft.com/library/d...n-us/dnpatterns/html/ImpSingletonInCsharp.asp)
and I found it useful but I still have a problem: what I need is a
thread-safe approach, because I expect to use this piece of code in
multi-threaded applications, but I'd like my class to be not "sealed" because
I would put some generic methods in it and I would add some specific
implementations in derived classes.
In the article above, instead, the class provided to obtain thread-safety is
designed "sealed", so that it doesn't completely suits my needs.
Bottom line: how can I implement a singleton class which is derivable and
thread-safe?
Or am I just thinking the whole thing wrong?
Thanks in advance.
Cheers,
baba.
I'm quite new to C#.
I am trying to implement some basics reusable classes using this language
and the .NET Framework technology.
What I'm trying to do now is to implement a singleton class.
I did have a look at the Microsoft "Patterns and Practices" article
"Implementing Singleton in C#"
(http://msdn.microsoft.com/library/d...n-us/dnpatterns/html/ImpSingletonInCsharp.asp)
and I found it useful but I still have a problem: what I need is a
thread-safe approach, because I expect to use this piece of code in
multi-threaded applications, but I'd like my class to be not "sealed" because
I would put some generic methods in it and I would add some specific
implementations in derived classes.
In the article above, instead, the class provided to obtain thread-safety is
designed "sealed", so that it doesn't completely suits my needs.
Bottom line: how can I implement a singleton class which is derivable and
thread-safe?
Or am I just thinking the whole thing wrong?
Thanks in advance.
Cheers,
baba.