Reputation: 765
I am new to Wcf and tried to create my first Wcf services. Added class(new assembly) which has unmanaged code and do file manipulation. Service behavior is set as follow
InstanceContextMode = InstanceContextMode.Single
ConcurrencyMode = ConcurrencyMode.Single
When service is accessed is single mode, the new file manipulation class is created. I noticed that if file manipulation class fail(memory leak or critical error) all new connections to host affected by previous connections.
Is it possible to create Wcf instances which are fully isolated between each other and fully destroyed after client connection is closed?
regards, Tomas
Upvotes: 1
Views: 151
Reputation: 755013
Yes, that's the preferred mode - it's called "per-call":
InstanceContextMode = InstanceContextMode.PerCall
ConcurrencyMode = ConcurrencyMode.Single
That way, each request coming into your WCF service will gets it own, separate, isolated instance of the service class, and that instance will handle the request and then be disposed.
That should give you maximum performance, and isolation of requests from one another.
Upvotes: 2