WCF stops responding after about 10 or so calls (throttling)

前端 未结 6 1191
抹茶落季
抹茶落季 2020-12-07 18:55

I have a WCF Service and an application with a Service Reference to it, and with the application I have a loop and in each iteration it\'s making a call to a method in this

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 19:15

    This can be solved by creating singleton class as interface between web service reference and application. Then it will create only one instance of service reference.

    class ServiceInterface
    {
         private static ServiceInterface  _instance;
         private ServiceClient _service = new ServiceClient ;
         private ServiceInterface()
         {
           //Prevent accessing default constructor
         }
    
         public static ServiceInterface GetInstance()
         {
    
         if(_instance == null)
    
         {
    
          _instance = new ServiceInterface();
    
        }
    
            return _instance;
    
    
    
     }
    
    
       // You can add your functions to access web service here
    
        Public int PerformTask()
        {
             return _service.PerformTask();
        }
    }
    

提交回复
热议问题