I have implemented singleton classes many times in the past without a problem. Perhaps dimentia is setting in, but today I found I couldn't make it work.
I'm using Visual Studio 2008, C#, and started with a simple:
I run a small app in the same solution and watch it start. From a similar program (different solution), I reference the same class library, but it creates a new instance even though the first one is still running.
I read http://msdn.microsoft.com/en-us/library/ff650316.aspx and tried every variation suggested, but no luck.
Okay, where did I go wrong?
Thanks in Advance! :-)
I'm using Visual Studio 2008, C#, and started with a simple:
Code:
public class justOne
{
private static justOne _justOne = null;
public static int LocalCounter;
private justOne() { LocalCounter = 0; }
public justOne getJustOne()
{
if (_justOne == null)
_justOne = new justOne();
return _justOne;
}
}
I read http://msdn.microsoft.com/en-us/library/ff650316.aspx and tried every variation suggested, but no luck.
Okay, where did I go wrong?
Thanks in Advance! :-)
Comment