Thanks.
Is there any other way to instantiate an object with application scope?
Regards
>> Thanks John, But it doesn't work!
>>
[quoted text clipped - 33 lines]
>
> nice clean examples at www.nicecleanexamples.com
John Mott - 11 Aug 2007 22:07 GMT
You can create a static member of the Application class (a static member can
be an object that can be modified, it doesn't have to be read-only). That
was my first idea but you didn't want a static variable. You may have
thought from that context that static meant 'readonly', it doesn't.
Does that help?
here's a link as well:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607
john
> Thanks.
> Is there any other way to instantiate an object with application scope?
[quoted text clipped - 37 lines]
>>
>> nice clean examples at www.nicecleanexamples.com
Milosz Skalecki [MCAD] - 12 Aug 2007 00:36 GMT
Hi there,
Usually, when the class cannot be static and you require one global instance
of a class, singleton pattern should be used (this is thread safe variant):
public class Global
{
private Global()
{
}
private static object sync = new object();
private static Global instance = null;
public Global Instance
{
get
{
lock(sync)
{
if (instance == null)
{
instance = new Global();
}
}
return instance;
}
}
}
// usage
Global global = Global.Instance;
In addition, in ASP.NET there's build-in mechanism for such scenarios called
Application state (instance can be initialized in the Global.asax
Application_Start event) or Caching (you'd have to make sure race condition
is eliminated).
HTH

Signature
Milosz
> Thanks.
> Is there any other way to instantiate an object with application scope?
[quoted text clipped - 37 lines]
> >
> > nice clean examples at www.nicecleanexamples.com
ma - 12 Aug 2007 10:10 GMT
Thanks,
Where can I read more about application instance or caching? Any good
tutorial on the web?
Regards
> Hi there,
>
[quoted text clipped - 82 lines]
>> >
>> > nice clean examples at www.nicecleanexamples.com
Milosz Skalecki [MCAD] - 12 Aug 2007 12:22 GMT
Hi,
There are many tutorials out there, ie:
http://samples.gotdotnet.com/quickstart/aspplus/doc/stateoverview.aspx
Google is your friend
Regards

Signature
Milosz
> Thanks,
> Where can I read more about application instance or caching? Any good
[quoted text clipped - 88 lines]
> >> >
> >> > nice clean examples at www.nicecleanexamples.com