Example #1
0
        void CreateClient()
        {
            NetTcpBinding     ntb         = new NetTcpBinding(SecurityMode.None);
            Uri               baseAddress = new Uri(urlToEndPoint);
            WSDualHttpBinding wsd         = new WSDualHttpBinding();
            EndpointAddress   ea          = new EndpointAddress(baseAddress);

            client = new TickWriterLS.TickWriterClient(new InstanceContext(this), ntb, ea);
        }
Example #2
0
 object ExecuteMethod()
 {
     isWorking = true;
     while (isWorking)
     {
         int avg = AverageLaseAccessTime;
         if (avg > 0)
         {
             int t = TotalMilisecondsFromLastAccess;
             if (AverageLaseAccessTime * 1.50 < t) // if don't have event more than 50% of average time
             {
                 _logger.Info(" " + t.ToString());
                 _logger.Info(String.Format("Don't have events more than {0}, trying to reconnect ...", t));
                 try
                 {
                     client = null;
                     Console.WriteLine("Try to reconnect...");
                     CreateClient();
                     Start();
                     client.SubscribeForEvent();
                     _logger.Info("Connected!");
                     listLastAccesedTime.Clear();
                     lastReceiveData = DateTime.MinValue;
                     Console.WriteLine("Success reconect");
                     threadSleepInMS = 100;
                 }
                 catch
                 {
                     _logger.Info("Unsuccesfull reconnect!");
                     client = null;
                     Console.WriteLine("Error");
                     if (threadSleepInMS < 5000)
                     {
                         threadSleepInMS += threadSleepInMS;
                     }
                 }
             }
         }
         Thread.Sleep(threadSleepInMS);
     }
     return(null);
 }