Singleton Classes
-
Hello everyone: Would you be able to give me some practical examples as to where I would need to implement Singleton classes? For e.g. if you could point out the scenarios where I must or should implement a Singleton class etc. I sure would appreciate your help. Thanks in advance. Regards, Robert
-
Hello everyone: Would you be able to give me some practical examples as to where I would need to implement Singleton classes? For e.g. if you could point out the scenarios where I must or should implement a Singleton class etc. I sure would appreciate your help. Thanks in advance. Regards, Robert
Singelton classes are used when you wan't to have only one instance of a class.
-------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
-
Singelton classes are used when you wan't to have only one instance of a class.
-------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
Dear CWIZO: Thanks a lot for your reply; I understand the concept of Singleton classes but for some reason I am unable to identify the scenario where I would need just one instance of a class. In other words 'why' would I need to have just one instance of a class? A practical (real world) example will be highly appreciated:). Thanks again. Regards, Robert
-
Dear CWIZO: Thanks a lot for your reply; I understand the concept of Singleton classes but for some reason I am unable to identify the scenario where I would need just one instance of a class. In other words 'why' would I need to have just one instance of a class? A practical (real world) example will be highly appreciated:). Thanks again. Regards, Robert
Well once could be a class for logging application errors. Since you don't wan't two clases write to the same file at once you make a singelton class.
-------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
-
Well once could be a class for logging application errors. Since you don't wan't two clases write to the same file at once you make a singelton class.
-------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
Maybe I'm way off base here, but wouldn't you either want multiple instances of this class so different threads don't change property data behind one another? Or maybe a static class so threads that need to log just call methods and pass the relevant data?