Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 27, 2012 07:38 PM by tilakrajchandan
Mar 15, 2011 10:56 AM|LINK
Could anyone please reply me if .NET Framework has any inbuilt Singleton class used?
Mar 15, 2011 11:38 AM|LINK
Nothing "built in", but here is a pretty straight forward article on implementing:
Mar 15, 2011 11:55 AM|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 12:09 PM|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 02:27 PM|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 10:43 AM|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 05:15 PM|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 07:37 AM|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 05:46 PM|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 07:38 PM|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.