J
Jonathan Rea
Hey,
I currently have the following code :
public sealed class FFManager
{
// Singleton pattern - single initialisation of FFManager for the
application
private static readonly FFManager instance = new FFManager();
private static bool FinalisePerformed = false;
public static FFManager Instance
{
get
{
return instance;
}
}
private FFManager()
{
// bla bla bla
}
}
The problem that I have is that the singleton class reads in a load of
definitions from a file to create many instances of a few classes. These
classes are required to talk to each other through the FFManager class in
order to configure themselves. The trouble comes in the fact that when
instance = new FFManager() is called, the created sub-classes call
FFManager.Instance. At this point the instance object in FFManager isnt
generated, and therefore an infinate loop is created (it keeps calling
instance = new FFManager(); ) and the program has a Stack Overflow
exception.
Is there a neat (or any) way round this, cos im damned if i can see it....
Many thanks
Jon
I currently have the following code :
public sealed class FFManager
{
// Singleton pattern - single initialisation of FFManager for the
application
private static readonly FFManager instance = new FFManager();
private static bool FinalisePerformed = false;
public static FFManager Instance
{
get
{
return instance;
}
}
private FFManager()
{
// bla bla bla
}
}
The problem that I have is that the singleton class reads in a load of
definitions from a file to create many instances of a few classes. These
classes are required to talk to each other through the FFManager class in
order to configure themselves. The trouble comes in the fact that when
instance = new FFManager() is called, the created sub-classes call
FFManager.Instance. At this point the instance object in FFManager isnt
generated, and therefore an infinate loop is created (it keeps calling
instance = new FFManager(); ) and the program has a Stack Overflow
exception.
Is there a neat (or any) way round this, cos im damned if i can see it....
Many thanks
Jon