Check out the discussion of singleton here:
http://www.yoda.arachsys.com/csharp/singleton.html
Sample code extracted from the above URL :
public sealed class Singleton
{
static Singleton instance=null;
static readonly object lock_obj = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
if (instance==null)
{
lock (lock_obj)
{
if (instance==null)
{
instance = new Singleton();
}
}
}
return instance;
}
}
}
No comments:
Post a Comment