WCF Concurrency means “Several computations are executing simultaneously.
WCF concurrency helps us configure how WCF service instances can serve multiple requests at the same time. You will need WCF concurrency for the below prime reasons; there can be other reasons as well but these stand out as important reasons:
We can use the concurrency feature in the following three ways:
- Single
- Multiple
- Reentrant
Single: A single request will be processed by a single thread on a server at any point of time. The client proxy sends the request to the server, it process the request and takes another request.
The following is the declaration of Concurrency.Single:
Multiple: Multiple requests will be processed by multiple threads on the server at any point of time. The client proxy sends multiple requests to the server. Requests are processed by the server by spawning multiple threads on the server object.
Reentrant: The reentrant concurrency mode is nearly like the single concurrency mode. It is a single-threaded service instance that receives requests from the client proxy and it unlocks the thread only after the reentrant service object calls the other service or can also call a WCF client through call back.
- [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple]
- Public class MyService : IMyService
- {
- }