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); }
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); } }
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); }
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); }
public HandleCounter(ITimerHandle hande) { this.CallCount = 0; this.THandle = hande; }