/// <summary> /// 达到时间间隔触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Timer_Elapsed(object sender, ElapsedEventArgs e) { lock (removeList) { TimerModel model = null; foreach (var id in removeList) { idModelDict.TryRemove(id, out model); } removeList.Clear(); } foreach (var model in idModelDict.Values) { if (model.Time <= DateTime.Now.Ticks) { model.Run(); } } }