Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No more potential than a SingleCall component. Both will have problems if they attempt to access a shared memory location in an unsafe manner. </p> <p>The difference between SingleCall and Singleton is that, for SingleCall , every incoming request will get a new instance of the defined type created to handle that call. Each instance will have its own memory space and instance variables, but they can still share static and global variables, external resources, files, network connections, etc. If the SingleCall class is coded to access any shared memory state in a thread-unsafe manner, then you will have issues. </p> <p>A Singleton, on the other hand, only gets one instance created for ALL incoming requests, so by definition, every instance variable in use within that singleton is, in fact, shared among all incoming requests. A good example might be a message publisher, that all code in the server needs to access to send messages to one or more subscribed clients....</p> <p>To address comment from @Cocowalla, make sure if you do this you override the method </p> <pre><code> MarshalByRefObject.InitializeLifetimeService() </code></pre> <p>as shown, or your singleton will die out unexpectedly if no one calls it for a while... </p> <pre><code>public class MessageManager : MarshalByRefObject { #region Singleton / MarshalByRefObject code private static MessageManager mgr = new MessageManager(); // creates singleton static MessageManager() { } private MessageManager() { } public static MessageManager Instance { get { return mgr; } } public override object InitializeLifetimeService() { return (null); } #endregion Singlelton code // ... other stuff ... } // in Remoting Host initialization code... MessageManager mgr = MessageManager.Instance; // generates singleton; RemotingServices.Marshal(mgr, URI); </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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