Esempio n. 1
0
        void PolicyTryConnect(IService ISvr)
        {
            if (ISvr.IsRuning)
            {
                return;
            }
            ConTry cT = dicTry[ISvr.Name];

            if (cT.IsTry)
            {
                return;
            }
            lock (cT) {
                if (ISvr.IsRuning || cT.IsTry)
                {
                    return;
                }
                cT.IsTry  = true;
                cT.Count += 1;
                int  nSleep  = 0;
                bool isError = false;
                ISvr.CloseAllChannels();
                do
                {
                    cT.TotalCount += 1;
                    nSleep        += 3;
                    isError        = TryIsError(ISvr);
                    if (isError)
                    {
                        nSleep %= 40;
                        System.Threading.Thread.Sleep(nSleep * 1000);
                    }
                }while (isError);
                cT.IsTry = false;
            }
        }
Esempio n. 2
0
 public void AddService(string Key, IService ISer)
 {
     dicServices[Key]         = ISer;
     dicTry[Key]              = new ConTry();
     ISer.ConnectionShutdown += ISer_ConnectionShutdown;
 }