Specifying a dedicated service instance for a singleton service
Normally, when hosting a WCF service, we only need to specify the service type in the ServiceHost
and the runtime will help create the service instance internally, according to the InstanceContextMode
we apply on the service class. This makes hosting a WCF service quite simple and convenient; the service developers do not need to know when and how the runtime creates the service instance. However, in some cases, it is useful and necessary to let the developer control when and how the service instance is created.
Getting ready
Singleton is one of the popular design patterns. This pattern can help design a class that will expose one and only one instance of the class over the entire ...
Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.