You can think of an AppDomain as a miniature process within a Win32
process (this is a very simplified view!).  Managed components in an
AppDomain cannot directly interact/interfere with components in another
AppDomain without using something like remoting.

In ASP.NET, each IIS "Application" gets its own AppDomain.  It will
outlive a single web service request.

However, if IIS or ASP.NET decides to recycle your application (doe to
memory usage, idle time, etc.), your AppDomain will go down.  Assuming
you haven't created a separate AppDomain for your singleton, your
singleton will disappear when the AppDomain goes down.

Greg Reinacker
Reinacker & Associates, Inc.
http://www.rassoc.com


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED]] On Behalf Of franklin gray
Sent: Friday, May 31, 2002 9:04 AM
To: [EMAIL PROTECTED]
Subject: Re: Singleton pattern


The remaining question I have is, What exactly is an AppDomain?

If my object is created from a Web Service call, is the Web Service the
AppDomain?  Does this imply that when the Web Service call is finished,
the AppDomain is no longer "Live"?

The reason I ask is because I am using this object like a in memory DB.
A Web Service call adds to a collection and another Web Service call
removes from the collection.  A bunch of these calls is the only
connection to the object.

I have a bug in the system and I haven't had the time yet to 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 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 will NOT be
called
for that object. That is it. Nothing more, nothing less.

-bc

On Fri, 31 May 2002 11:37:52 +0200, Jonni Faiga <[EMAIL PROTECTED]> wrote:

>Hi,
>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 C# version is make sure you have a
>live reference to the singleton object for as long as it's needed." is
>incorrect.
>
>
>btw. Any idea why the Rational XDE generated code for a singleton has a
>public constructor?
>
>public class Singleton
>{
>        public void singletonOperation()
>        {
>        }
>
>        public static Singleton getUniqueInstance()
>        {
>                if(uniqueInstance == null)
>                {
>                        uniqueInstance = new Singleton();
>                }
>                return uniqueInstance;
>        }
>
>        public System.Object getSingletonData()
>        {
>                return singletonData;
>        }
>
>        public Singleton()
>        {
>        }
>
>        static Singleton uniqueInstance;
>        System.Object singletonData;
>}
>
>You can read messages from the Advanced DOTNET archive, unsubscribe
from
Advanced DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to