views:

164

answers:

2

I have self hosted net tcp WCF service that exposes two methods and the service is not thread safe and it is (PerSession) .

I found that my colleague developer who is using the service, accesses the same service object from different threads, and till now it works fine.

So I am asking if you have parallel call from the same client then the service will serial? or I am wrong? and is that good to access wcf service object from different threads?

+1  A: 

The "per session" is the "instance context mode" - this just guarantees to give you the same service-side object (implementing the service) for the duration of the session. I believe you should look at the "concurrency mode". If this is "single" then the calls are synchronized (serial) - but that isn't the only setting; "multiple" and "re-entrant" would allow multiple threads into the service at once.

Marc Gravell
okay, I am asking about the different calls from the same client, and what is the default concurrency mode because I did not mention it on the service
Ahmed Said
The default is single, so yes they would be serial. Note that this is used *in combination* with the instance context mode - so only calls on the same session will be serialized (but two different sessions with separate svc objects can run in parallel).
Marc Gravell
A: 

Chapter 8 of Juval Lowy's "Programming WCF Services" contains pretty much everything you might possibly need to know about concurrency with WCF. It's the unofficial "bible" of WCF. I strongly suggest checking it out.

Terry Donaghe