其他

You are developing a Windows Communication Foundation (WCF) service.One of the service operations contains the following code.private static int counter = 0;[OperationContract]public void IncrementCount(){ counter++;}You need to set a service behavior tha

题目

You are developing a Windows Communication Foundation (WCF) service.One of the service operations contains the following code.private static int counter = 0;[OperationContract]public void IncrementCount(){ counter++;}You need to set a service behavior that prevents two or more threads from incrementing the counter variable at the same time.Which code segment should you use to set the service behavior?()

A. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]

B. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]

C. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]

D. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Reentrant)]

如果没有搜索结果,请直接 联系老师 获取答案。
更多相关问题