Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think, if you want a thread safety, you should use this way:</p> <pre><code>internal sealed class SektionCache : CacheBase { //public static readonly SektionCache Instance = new SektionCache(); // this template is better ( safer ) than the previous one, for thread-safe singleton patter &gt;&gt;&gt; private static SektionCache defaultInstance; private static object readonly lockObject = new object(); public static SektionCach Default { get { SektionCach result = defaultInstance; if ( null == result ) { lock( lockObject ) { if ( null == result ) { defaultInstance = result = new SektionCache(); } } } return result; } } // &lt;&lt;&lt; this template is better ( safer ) than the previous one //private static readonly object lockObject = new object(); //private static bool isUpdating; //private IEnumerable&lt;Sektion&gt; sektioner; // this declaration is enough private volatile IEnumerable&lt;Sektion&gt; sektioner; // no static constructor is required &gt;&gt;&gt; //static SektionCache() //{ // UpdateCache(); //} // &lt;&lt;&lt; no static constructor is required // I think, you can use getter and setter for reading &amp; changing a collection public IEnumerable&lt;Sektion&gt; Sektioner { get { IEnumerable&lt;Sektion&gt; result = this.sektioner; // i don't know, if you need this functionality &gt;&gt;&gt; // if ( null == result ) { result = new Sektion[0]; } // &lt;&lt;&lt; i don't know, if you need this functionality return result; } set { this.sektion = value; } } //public static void UpdateCache() //{ //// SNIP - getting data, locking etc. //Instance.sektioner = newSektioner; //// SNIP //} } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload