开发者

How to split WCF service's Operation contracts into Concurrency mode as Single and Multiple

开发者 https://www.devze.com 2023-04-11 22:29 出处:网络
I have one service Service A with 2 operation contract CheckServer and AddService. As the Service is singleton with Concurrey mode as Single

I have one service Service A with 2 operation contract CheckServer and AddService. As the Service is singleton with Concurrey mode as Single [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single)]

public Class Service : Iservice
{
   public bool CheckService()
    {
       //Checks server avilabality and returns bool value
    }

   public int AddService(int a, int b)
    {
      return int i = a + b;
    }
}

Here my requirement is only one Instace of AddService to be allowed, so I made this as singleton. Now CheckServvice is not necessary to be Singleton so how can I split these 2 method implementation to make AddService as singleton and CheckService as开发者_如何学JAVA multiple.

Thanks in Advance


WCF doesn't provide what you want. Put that logic outside of WCF and write your own synchronization logic. For example implement singleton class exposing CheckService and AddService where synchronization will be directly in AddService method and CheckService method will be free to call.

Make standard WCF per-call service delegating processing to your singleton class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号