Exemplo n.º 1
0
        public TimerCollection Boot(string timerJsonPath)
        {
            if (!System.IO.File.Exists(timerJsonPath))
            {
                throw new System.IO.FileNotFoundException(timerJsonPath);
            }
            jsonTm = new JsonTimer(timerJsonPath);
            List <JsonTimerItem> listJTimer = jsonTm.Read();

            foreach (JsonTimerItem jtItem in listJTimer)
            {
                AnXTimer xTimer = new AnXTimer(jtItem);
                foreach (HandlerConfig hConfig in jtItem.Handlers)
                {
                    ITimerHandle tHandler = null;
                    if (xTimer.IsStrictTimer)
                    {
                        tHandler = new Impl.AsynPostHandlerImpl(hConfig);
                    }
                    else
                    {
                        tHandler = new Impl.SynPostHandlerImpl(hConfig);
                    }
                    xTimer.AddHandle(hConfig.Name, tHandler);
                }
                tc.Add(xTimer.Name, xTimer);
            }
            jsonTm.OnChange += jsonTm_OnChange;
            return(tc);
        }
Exemplo n.º 2
0
 public void AddHandle(string Key, ITimerHandle handle)
 {
     if (dicHandle.ContainsKey(Key))
     {
         return;
     }
     lock (ObjLock) {
         HandleCounter hc = new HandleCounter(handle);
         dicHandle[Key] = hc;
         addLog(EnumAction.添加, Key);
     }
 }
Exemplo n.º 3
0
        public AnXTimer BuildTimer(JsonTimerItem timerItem)
        {
            AnXTimer xT       = new AnXTimer(timerItem.Name);
            bool     isStrict = timerItem.Strict == 1;

            foreach (HandlerConfig hc in timerItem.Handlers)
            {
                ITimerHandle iT = BuildHandler(isStrict, hc);
                xT.AddHandle(hc.Name, iT);
            }
            return(xT);
        }
Exemplo n.º 4
0
        public ITimerHandle BuildHandler(bool isStrict, HandlerConfig hConfig)
        {
            ITimerHandle iT = null;

            if (isStrict)
            {
                iT = new Impl.AsynPostHandlerImpl(hConfig);
            }
            else
            {
                iT = new Impl.SynPostHandlerImpl(hConfig);
            }
            return(iT);
        }
Exemplo n.º 5
0
 public HandleCounter(ITimerHandle hande)
 {
     this.CallCount = 0;
     this.THandle   = hande;
 }