Do I need to implement my own locking in a WCF service that uses ConcurrencyMode.Multiple and InstanceContextMode.PerCall or InstanceContextMode.PerSession? Since a new ServiceContext object is created at every call or new session I should think that I would not, but I’m far from sure.
Example:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession,
IncludeExceptionDetailInFaults = false, MaxItemsInObjectGraph = Int32.MaxValue)]
public class ExampleService : IExample
No you don’t have to add locking. Each call will get a fresh instance.
However, if you need state from a particular caller, that will have to be handled manually.
See this thread for more information