示例#1
0
 public void Remove(TimedItem <TEArtsType> item)
 {
     if (item == null)
     {
         return;
     }
     lock (List)
     {
         if (List.ContainsKey(item.TimeOut))
         {
             List[item.TimeOut].Remove(item);
         }
         if (List[item.TimeOut].Count == 0)
         {
             List.Remove(item.TimeOut);
             NextTimer();
         }
     }
 }
示例#2
0
 public TimedItem <TEArtsType> Add(TimedItem <TEArtsType> i)
 {
     if (i.TimeOut <= DateTime.Now)
     {
         i.Callback?.Invoke(i.Item);
     }
     else
     {
         lock (List)
         {
             if (!List.TryGetValue(i.TimeOut, out List <TimedItem <TEArtsType> > ts))
             {
                 ts = new List <TimedItem <TEArtsType> >();
                 List.Add(i.TimeOut, ts);
             }
             ts.Add(i);
             NextTimer();
         }
     }
     return(i);
 }