Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>good responses, but I think there is a problem in the original question. "Typical use" of a technology is a poorly formed question. No one has a "typical" scenario, and you should review the requirements of your particular problem before deciding on an implementation or approach. Your requirements should inform your solution.</p> <p>For instance, Singletons [ie the Singleton pattern] is just another tool in our box, and like any tool, there are cases where it works, and others it does not. Specifically, if you need to centralize business logic [more applicable in a standalone application than a remote WCF service], or share memory or a resource, a Singleton works well. Of course, if you are sharing business logic, state is maintained in the call stack, and multi threading is moot. If sharing memory between consumer calls, then multi threading is an issue. As regards WCF, there are two modes [actually three, but the third is a special case of the first] of multi-threading behaviour you can specify,</p> <pre><code>// we are specifying that this service implementation is single-threaded // and WCF should permit *at most* one call at a time. Any requests made // simultaneously/concurrently are queued. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single)] public class SingleThreadedNonThreadSafeService : IService { ... } </code></pre> <p>and </p> <pre><code>// we are specifying that this service implementation is multi-threaded // and [hopefully!] thread-safe. WCF should permit any number of threads, // or any number of simultaneous concurrent calls. [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] public class MultiThreadedThreadSafeService : IService { ... } </code></pre> <p>The Xml comments for <code>ConcurrencyMode</code> basically say the same thing as above.</p> <p>If you <strong>DO NOT</strong> need to share business logic or memory between consumers, then <strong>DO NOT</strong> use a Singleton, the "model" <strong>DOES NOT</strong> fit the problem. It's like forcing a glass slipper on a step-sister's foot! And no one should ever have to see that.</p> <hr> <p>Conversely, if no state is shared between calls, host an instance per-call\session.</p>
 

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