< Day Day Up > |
TechniqueTo configure a remoting object as a singleton object, all you have to do is call the method RegisterWellKnownServiceType with the option WellKnownObjectMode.Singleton : RemotingConfiguration.RegisterWellKnownServiceType( typeof(_1_RemoteObject.RemoteObject), "Demo", WellKnownObjectMode.Singleton); CommentsConfiguring the object as a singleton object has the effect that only one object is created, and every client gets a reference to the same object. With such a behavior, you have to pay attention to threading issues. With multiple clients, the same object might be accessed from multiple threads simultaneously , and you have to pay attention to locking issues. Singleton objects do have a timeout with the leasing mechanism similar to client-activated objects. Recipe 18.9 discusses how you configure the timeout values. |
< Day Day Up > |