February 2003
Intermediate to advanced
752 pages
16h 35m
English
Singleton objects resemble client-activated objects in that they retain state; but the server, not the client, creates them. Only one instance of a singleton object is ever created, and it can serve any number of concurrent clients. Because the .NET Remoting services are multithreaded, clients can call methods on this object simultaneously. However, you must ensure that the object itself is thread-safe. If you modify a member variable in a singleton method, for example, you must ensure that you obtain an exclusive lock first. Otherwise, updates might be lost or inconsistent data might be applied.
We can alter the preceding example to use a singleton object without worrying. The single GetActiveDomain method just returns a static ...