Concurrency mode helps us configure allowed number of concurrent calls for a service. This can be enabled by using a class level attribute Service Behavior. Concurrency mode property supports 3 values.
- Single, 2. Multiple and 3. Reentrant
Single: System restricts instance creations of the service to one thread of execution at a time.
Multiple: This enables system to execute server objects in multiple threads at any one time. We should ensure thread safety.
Reentrant: Enables us to restrict server object to process operations at a time. If any other object is leaves the operation, this frees up the lock on the operation, so the current process can enter the operation execution.
When Concurrency Mode is set to we need to maintain user state at client state. This is achieved by setting session mode property to require. Also we need to set IsInitiating and Isterminating properties to true at the operation contract level.
IsInitiating property allows system to create a session and Isterminating property allows us to forcefully close the session.