The text of this article is not in this database — only its details are. Read it on the old site: Learn Design Pattern - Singleton Pattern
7 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: Learn Design Pattern - Singleton Pattern
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Mazhar PashaPosted May 22, 2017, 6:30 AM
Hi Sukesh, If we want to create Singleton Pattern then class should be Sealed Right? In you are example its not sealed. Can you please explain me on this. And correct me if my understanding is wrong.
Sai SherlekarPosted Jun 29, 2013, 3:29 PM
Basically my question is we can do these things without this private constructor, singleton. then what is the use?
Sai SherlekarPosted Jun 29, 2013, 3:27 PM
sukesh i m not clear. can u explain me in detail. bcz to save settings across all user we can create normal class who has static property. if i want to share per user then i will store simple class object in session, and for per request no need to do anything just create simple object
Sukesh MarlaPosted Mar 8, 2013, 9:40 PM
WC, my pleasure
Shivani GuptaPosted Feb 28, 2013, 11:49 PM
Singleton with nice presentation.. thanks
Nikhil ShekharPosted Oct 31, 2012, 2:37 PM
@Sandeep - As "objPriSingleton" is a static object, hence CLR will ensure that it is created on only one thread, making it thread safe. Im not sure if the ASP.net implementation using "HttpContext.Current...." is thread safe. If you are creating an object through a method then you should use locking. Below is a good explanation of singelton pattern creation with object lock: http://msdn.microsoft.com/en-us/library/ff650316.aspx
Sandeep Singh ShekhawatPosted Sep 20, 2012, 7:41 AM
Thanks, its helpful and enjoy to reading this. But how can check that instance already exists or not in GetObject and Is it threadsafe object? can you please explain?