Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-20 Thread Stefan Holdermans
Frank wrote: > So we can say the static constructors are thread-safe, unless they end up > calling static methods in other classes? And if they do this, the static > methods need to be made thread-safe? I think that pretty much covers it. It's good practice to make your static methods thread-sa

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-18 Thread Bill Caputo
Frank Hileman: >I don't see how a function can be guaranteed to be executed only >once, and be thread unsafe. I am not saying that static constructors are not thread safe (I do not know), but a not thread safe implementation of the above could be something as simple as (psuedo code): class Stati

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-18 Thread Stefan Avramtchev
I think the type contructors is thread safe. How otherwise is the framework guarding this rule if not by locking some internal object (not the being-initialised class ofcourse) in order to guarantee that only one thread runs inside the type contructor? stef On Fri, 14 Jun 2002 15:01:22 -0700,

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-15 Thread Keith Hill
On Thu, 13 Jun 2002 10:50:24 -0700, Frank Hileman <[EMAIL PROTECTED]> wrote: >> >"The static constructor for a class executes at most one time during a >> >single program instantiation" The more I think about it, the statement above does not imply thread- safety, at least not to me. Can someone

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-14 Thread Frank Hileman
Hello, I got it from the latest MSDN library CD. I imagine that behavior is in the current spec, worded differently. Regards, Frank - Original Message - From: "Keith Hill" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 12, 2002 10:45 PM Subject

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-13 Thread Keith Hill
On Thu, 6 Jun 2002 08:19:46 -0700, Frank Hileman <[EMAIL PROTECTED]> wrote: >Why do you have all this locking code? A static constructor is already >thread-safe. From C# spec: > >"The static constructor for a class executes at most one time during a >single program instantiation" I could not find

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-11 Thread Stefan Holdermans
Frank wrote: >Static methods provide no more encapsulation than instance methods. Static >methods are less flexible because they cannot be virtual. I don't see any >advantage. But I think Ben's question issued choosing between establishing public visisbility to the static field and providing a s

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-09 Thread Ben Kloosterman
:[EMAIL PROTECTED]]On Behalf Of Peter Meinl Sent: Sunday, 9 June 2002 7:12 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern This article discusses the singelton pattern and its Gof and .NET implementation: Exploring the Singleton Design Pattern http://msdn.microsoft.com

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-09 Thread Peter Meinl
This article discusses the singelton pattern and its Gof and .NET implementation: Exploring the Singleton Design Pattern http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnbda/html/singletondespatt.asp -- Peter Meinl ISTEC GmbH You can read messages from the Advanced DOTNET arch

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-09 Thread Axel Heitland
: [ADVANCED-DOTNET] Singleton pattern Frank, (Sorry, I'm way late with this reply... I took a few days off and actually enjoyed other things than coding and thinking about it... ;)) On Thu, 6 Jun 2002 08:06:13 -0700, Frank Hileman <[EMAIL PROTECTED]> wrote: >Regarding static var for sing

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-09 Thread Frank Hileman
I don't approve of public fields either. My point was, the best way to implement the singleton pattern is to use a static field, optionally with a static constructor. This is automatically thread-safe, and the object will not be constructed until the class is used. No need for locking, etc. Here i

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-09 Thread Thomas Tomiczek
Holdermans [mailto:[EMAIL PROTECTED]] Sent: Samstag, 8. Juni 2002 17:50 To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern Frank, (Sorry, I'm way late with this reply... I took a few days off and actually enjoyed other things than coding and thinking about it... ;)) On Thu,

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-08 Thread Stefan Holdermans
Frank, (Sorry, I'm way late with this reply... I took a few days off and actually enjoyed other things than coding and thinking about it... ;)) On Thu, 6 Jun 2002 08:06:13 -0700, Frank Hileman <[EMAIL PROTECTED]> wrote: >Regarding static var for singleton: I found that static vars are not >init

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-07 Thread Brad Wilson
Joseph Bustos wrote: > Do you know a vb.net to c# tool? Anakrino. It's an "anything to C#" tool! :) http://www.quality.nu/dotnetguy/other/freedevtools.aspx#cat5 Brad -- Read my web log at http://www.quality.nu/dotnetguy/ You can read messages from the Advanced DOTNET archive, unsubscribe fro

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-07 Thread franklin gray
nope, sorry. -Original Message- From: Joseph Bustos [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 5:38 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern Do you know a vb.net to c# tool? -Original Message- From: franklin gray [mailto:[EMAIL

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-07 Thread Joseph Bustos
Do you know a vb.net to c# tool? -Original Message- From: franklin gray [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 06, 2002 1:19 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern http://www.aspalliance.com/aldotnet/examples/translate.aspx -Original

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-06 Thread Frank Hileman
Regarding static var for singleton: I found that static vars are not initialized until the first time you use the class. If you don't use the class, they are never initialized. So your one argument against using a static var is refuted. As another poster pointed out, your code is not thread-safe.

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-06 Thread franklin gray
Brian: I ran this through the C# to Vb web tool and below is what I got (After I took out the comments). Questions: 1) What is _value? 2) How is it different from the bottom class? What functionality does it give me that the bottom class doesn't? 3) What is volatile? NotInheritable Pub

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-06 Thread Ian Griffiths
Of course the problem with this is that it it is not thread safe. You could go with a hybrid: public sealed class Singleton { private static Singleton TheSingleton = new Singleton(); public static Singleton Singleton { get { return sobjSingleton; } } private

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-06 Thread Stefan Holdermans
Just to come up with a good reason to go for public sealed class Singleton { private static Singleton sobjSingleton; public static Singleton GetSingleton { if (sobjSingleton == null) sobjSingleton = new Singleton(); return sobjSingleton; } privat

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-04 Thread Mike Woodring
ture like ASP.NET. -Mike http://staff.develop.com/woodring http://www.develop.com/devresources - Original Message - From: "Jonni Faiga" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 04, 2002 7:07 AM Subject: Re: [ADVANCED-DOTNET] Singleton pattern Hi,

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-03 Thread Ben Kloosterman
advanced .NET topics. [mailto:[EMAIL PROTECTED]]On Behalf Of Shawn Wildermuth Sent: Monday, 3 June 2002 2:24 AM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern I've been using static classes for singleton's. Is this a bad approach? Are static constructor's unrelia

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-03 Thread Greg Reinacker
discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED]] On Behalf Of Noam Arbel > Sent: Saturday, June 01, 2002 12:39 PM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Singleton pattern > > > I think it is usefull to understand when SuppressFinalize(

Re: [ADVANCED-DOTNET] Singleton pattern

2002-06-02 Thread Greg Reinacker
figure it out so I am wondering if this is the problem (I don't think it is though). -Original Message- From: Bill Conroy [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 8:02 AM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Singleton pattern This is Bill, and I'm quite

Re: [ADVANCED-DOTNET] Singleton pattern

2002-05-31 Thread Bill Conroy
This is Bill, and I'm quite sure I'm right. Actually, I'm positive. And Bajaj is correct also. It's all about the static and setting it means there will be a root reference for as long as the AppDomain is "live", thus it will not be GC'd. SuppressFinalize only ensures that the Finalize method wil

Re: [ADVANCED-DOTNET] Singleton pattern

2002-05-31 Thread Mike Woodring
- Original Message - From: "Jonni Faiga" <[EMAIL PROTECTED]> Bills conclusion that SuppressFinalize is not required implies that Samir Bajaj's statement regarding has Singleton code in http://msdn.microsoft.com/msdnmag/issues/01/07/patterns/patterns.asp is that "all you need to do in the