WCF Tutorial
Lesson 62 of 236 · Part 45 Reentrant concurrency mode in WCF · Database
Part 45 Reentrant concurrency mode in WCF
Link for all dot net and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat/playlists
Link for code samples used in the demo
http://csharp-video-tutorials.blogspot.com/2014/04/part-45-reentrant-concurrency-mode-in.html
In this video we will discuss the Reentrant concurrency mode in WCF with an example.
Reentrant mode allows the WCF service to issue callbacks to the client application.
1. The WCF service concurrency mode is set to Single. This means only one thread is allowed to access the service instance.
2. Client makes a request to the WCF Service. The service instance gets locked by the thread that is executing the client request. At this point no other thread can access the service instance, until the current thread has completed and released the lock.
3. While the service instance is processing the client request, the service wants to callback the client. The callback operation is not one way. This means the response for the callback from the client needs to get back to the same service instance, but the service instance is locked and the response from the client cannot reenter and access the service instance. This situation leads to a deadlock.
There are 2 ways to solve this problem.
1. Set the concurrency mode of the WCF service to Reentrant.
OR
2. Make the callback operation oneway. When the callback operation is made oneway, the service is not expecting a response for the callback from the client, so locking will not be an issue.