Last post Dec 27, 2012 03:38 PM by tilakrajchandan
Mar 15, 2011 06:56 AM|duttavr|LINK
Could anyone please reply me if .NET Framework has any inbuilt Singleton class used?
Mar 15, 2011 07:38 AM|tehremo|LINK
Nothing "built in", but here is a pretty straight forward article on implementing:
Mar 15, 2011 07:55 AM|duttavr|LINK
Thanks tehremo for the reply.
Sorry If my question was not clear. I know how to implment.
I'm just trying to find if any real time example where .NET Framework already used it.
Mar 15, 2011 08:09 AM|naveenj|LINK
The site dofactory.com has some examples for doing in C# and .NET Optimized environment.
Check out this link: Singleton Design Pattern
Mar 15, 2011 10:27 AM|duttavr|LINK
Let me reiterate my query.
I would just like to know if Microsoft implemented Singleton class in any of Microsoft's frameworks.
Prefarablly in below as I work with them.
Apr 05, 2011 06:43 AM|vibhumittal|LINK
If you consider Application object in asp.net you will find it implemented as singleton as Application object is shared throuughout the application and
no other instance of same can exists.
Apr 05, 2011 01:15 PM|duttavr|LINK
No, Application is property of type HttpApplicationState.
HttpApplicationState is just a sealesed public class, it's not created a singleton class.
However logically Application property will be assigned with only one object throught the application.
mutliple application objects to HttpApplicationState will be created for muliple applications.
So it is just logically mainted as singleton rather created HttpApplicationState as singleton class.
I agree that implementation alwasy can be altered to our needs., however, I could not see any realtime class defined as singleton physically as mentioned in GangOfFour example.
Jun 01, 2012 03:37 AM|dskcheck|LINK
All the static objects from BCL are implemented as Singleton pattern. If you need an example to justify my statement, please see the below code
lblTime.ForeColor = SystemColors.ControlText;
I'm sure that you must be aware that the SystemColors is a class.
On a second thought, check for the information about
DataRowComparer. This static class DataRowComparer is a member of System.Data.
The summary for this static class is mentioned by Microsoft as, "Returns a singleton instance of the System.Data.DataRowComparer<TRow> class."
Hope this helps.
Aug 16, 2012 01:46 PM|kushalrdalal|LINK
I think so when you host the wcf service internally microsoft uses singleton to make sure it has only one instance available.
Check this links-
Dec 27, 2012 03:38 PM|tilakrajchandan|LINK
Your explanation is ambiguous. ServiceHost is not singleton. SingletonInstance points to service object which is passed when
ServiceHost(Object, uri) syntax is used. If Other syntax is used which accepts type (and InstanceContextMode is not single, this object is null.