public void Remove(TimedItem <TEArtsType> item) { lock (List) { if (List.ContainsKey(item.TimeOut)) { List[item.TimeOut].Remove(item); } if (List[item.TimeOut].Count == 0) { nextTimer(); } } }
public TimedItem <TEArtsType> Add(TimedItem <TEArtsType> i) { if (i.TimeOut <= DateTime.Now) { i.ResetTime(); } long m = 0; TimeSpan t = (i.TimeOut - DateTime.Now); if (t.TotalMilliseconds > long.MaxValue) { m = long.MaxValue; i.NextTimer = t.TotalMilliseconds - long.MaxValue; } else { m = (long)(t.TotalMilliseconds); } List <TimedItem <TEArtsType> > ts = null; lock (List) { if (List.ContainsKey(i.TimeOut)) { ts = List[i.TimeOut]; } else { ts = new List <TimedItem <TEArtsType> >(); } ts.Add(i); if (Next > i.TimeOut) { Timer.Change(m, Timeout.Infinite); } } return(i); }
public TimedItem <TEArtsType> Add(TEArtsType item, long mill, Action <TEArtsType> onTimeOut) { TimedItem <TEArtsType> i = new TimedItem <TEArtsType>(Millisecond); return(Add(i)); }