Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on what you need. If you need a <strong>single</strong> instance of your service to be instantiated for the life time of the application you might want to use single. You might do this for instance if instantiating that service was extremely expensive for some reason and it was not called very often so you weren't concerned about multiple threads hitting it at the same time.</p> <pre><code> [ServiceBehavior(Namespace = "http://somenamespace", InstanceContextMode = InstanceContextMode.Single)] public sealed class ServiceWithExpensiveDictionary : IServiceWithExpensiveDictionary, IDisposable { private DataCacheFactory factory; private ConcurrentDictionary&lt;string, DataCache&gt; dataCacheDictionary; /// &lt;summary&gt; /// Constructor /// &lt;/summary&gt; public ServiceWithExpensiveDictionary() { factory = new DataCacheFactory(); dataCacheDictionary = new ConcurrentDictionary&lt;string,DataCache&gt;(); } </code></pre> <p>In the code above, I want the ConcurrentDictionary instance to be around for all callers of the service as I'm putting expensive objects into it.</p> <p>You might use <strong>session</strong> if you were intending users to have stateful long-running conversations with your api.</p> <p>You might use <strong>per call</strong> if your services were stateless and service instantiation was cheap.</p> <p>It really depends on what you want to do.</p> <p>There is also a nice question related to this here. It also touches on throttling which you might also be interested in:-</p> <p><a href="https://stackoverflow.com/questions/7122608/wcf-concurrencymode-single-and-instancecontextmode-percall">WCF ConcurrencyMode Single and InstanceContextMode PerCall</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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