Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 30, 2011 08:29 PM by sun21170
May 30, 2011 07:29 PM|LINK
I have 3 web methods in a WCF, called 'DeleteGroup', 'AddGroup', 'ModifyGroup'.
Each method has its own code. I want to place a lock on code within each method, so that only one method executes at a time. For example, if 'DeleteMethod' is being executed then no request for 'AddGroup' or 'ModifyGroup' can be executed. So may be I could
use something like what is below, but not very sure ? Also, where in the WCF would I declare the locker object, and would it be private, public or static (i.e. shared)?
--Delete Method Body
--Modify Method Body
--Add Method Body
May 30, 2011 07:49 PM|LINK
To perform locking in WCF Service you have to use ConcurrencyMode attribute with your service methods.
"When the service is set with ConcurrencyMode.Single, WCF will provide automatic synchronization to the service instance and disallow concurrent calls by associating the service instance with a synchronization lock". Please see http://codeidol.com/csharp/wcf/Concurrency-Management/Service-Concurrency-Mode/
May 30, 2011 08:21 PM|LINK
I think the concurrency you have described will make the entire instance of WCf a single threaded app. I want concurrent calls to methods allowed provided these methods get data/change data that are not inter-related. For example, the 'AddGroup' method and
the 'AddCustomer' methods can be executed at the same time since their actions are completely independent of each other.
So it seems the WCF solution that you have recommended is not a good approach for my case since it will slow down the WCF response.
Do you have any other ideas?
May 30, 2011 08:29 PM|LINK
Also, my WCF has the following configuration, and so synchronization is provided by WCF only for the instance created for the WCF: