<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Singleton shortcut</title>
	<atom:link href="http://blog.cincura.net/230783-singleton-shortcut/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cincura.net/230783-singleton-shortcut/</link>
	<description>Taking something that can&#039;t be done, and then doing it.</description>
	<lastBuildDate>Wed, 08 Feb 2012 15:02:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: alvar</title>
		<link>http://blog.cincura.net/230783-singleton-shortcut/#comment-1968</link>
		<dc:creator>alvar</dc:creator>
		<pubDate>Thu, 27 Aug 2009 14:10:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230783#comment-1968</guid>
		<description>The simplest singleton:
    public sealed class BestSingleton
    {
        /// Best implementation of singleton pattern.
        /// What we really care about is that we get the instance created either on or just before the 
        /// first call to (in this case) the Instance property, and that we have a defined initialization order 
        /// for static variables in a class. With the .NET Framework, this is exactly the behavior we get. 
        /// The Framework, during the JIT process, will initialize the static property when (and only when) any method 
        /// uses this static property. If the property is not used, then the instance is not created. 
        /// More precisely, what happens during JIT is that the class gets constructed and loaded when any static member 
        /// of the class is used by any caller. In this case the result is the same.
        /// What about thread-safe initialization? The Framework addresses this too. The Framework internally guarantees 
        /// thread safety on static type initialization. In other words, in the example above, there is only one instance 
        /// that would ever be created of the Singleton class. Note also that the property field used to hold the instance 
        /// of the class is called Instance. This choice better illustrates that this value is an instance of the class. 
        /// In the Framework itself there are several classes that use this type of singleton, although the property name used 
        /// is called Value instead. The concept is exactly the same.
        /// 
		static BestSingleton(){} // Removes beforefieldinit flag from the type
        public static readonly BestSingleton Instance = new BestSingleton();
        private BestSingleton() {/*construct the only instance*/}
    }</description>
		<content:encoded><![CDATA[<p>The simplest singleton:<br />
    public sealed class BestSingleton<br />
    {<br />
        /// Best implementation of singleton pattern.<br />
        /// What we really care about is that we get the instance created either on or just before the<br />
        /// first call to (in this case) the Instance property, and that we have a defined initialization order<br />
        /// for static variables in a class. With the .NET Framework, this is exactly the behavior we get.<br />
        /// The Framework, during the JIT process, will initialize the static property when (and only when) any method<br />
        /// uses this static property. If the property is not used, then the instance is not created.<br />
        /// More precisely, what happens during JIT is that the class gets constructed and loaded when any static member<br />
        /// of the class is used by any caller. In this case the result is the same.<br />
        /// What about thread-safe initialization? The Framework addresses this too. The Framework internally guarantees<br />
        /// thread safety on static type initialization. In other words, in the example above, there is only one instance<br />
        /// that would ever be created of the Singleton class. Note also that the property field used to hold the instance<br />
        /// of the class is called Instance. This choice better illustrates that this value is an instance of the class.<br />
        /// In the Framework itself there are several classes that use this type of singleton, although the property name used<br />
        /// is called Value instead. The concept is exactly the same.<br />
        ///<br />
		static BestSingleton(){} // Removes beforefieldinit flag from the type<br />
        public static readonly BestSingleton Instance = new BestSingleton();<br />
        private BestSingleton() {/*construct the only instance*/}<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cincura.net</title>
		<link>http://blog.cincura.net/230783-singleton-shortcut/#comment-1965</link>
		<dc:creator>cincura.net</dc:creator>
		<pubDate>Wed, 26 Aug 2009 20:32:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230783#comment-1965</guid>
		<description>I don&#039;t care about thread safety in this example. In fact when I need thread safety I often need more than this (i.e. fine grained locking in methods too etc.).</description>
		<content:encoded><![CDATA[<p>I don&#8217;t care about thread safety in this example. In fact when I need thread safety I often need more than this (i.e. fine grained locking in methods too etc.).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: André</title>
		<link>http://blog.cincura.net/230783-singleton-shortcut/#comment-1964</link>
		<dc:creator>André</dc:creator>
		<pubDate>Wed, 26 Aug 2009 20:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.cincura.net/?p=230783#comment-1964</guid>
		<description>Don&#039;t use this. They are both the same and not thread safe.

When I use singleton, I prefer version 4 from here:

http://www.yoda.arachsys.com/csharp/singleton.html</description>
		<content:encoded><![CDATA[<p>Don&#8217;t use this. They are both the same and not thread safe.</p>
<p>When I use singleton, I prefer version 4 from here:</p>
<p><a href="http://www.yoda.arachsys.com/csharp/singleton.html" rel="nofollow" target="_blank">http://www.yoda.arachsys.com/csharp/singleton.html</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

