//将dtu加入到dtu列表中 要求线程安全的 public void AddTaskItem(BaseDTU item) { lock (baseDTUList) { baseDTUList.Add(item); } }
/// <summary> /// 把到来的实际dtu下分到具体的BaseTimer中 /// </summary> /// <param name="baseDTU"></param> public void AddDTU(BaseDTU baseDTU) { object o = new object(); lock (o) { //计算新的baseDTU应该被放置在哪一个BaseTimer中 int tempIndex = (int)(index++) % baseTimerList.Count; baseTimerList.ElementAt(tempIndex).AddTaskItem(baseDTU); } }
public void RemoveDTU(BaseDTU baseDTU) { object o = new object(); lock (o) { foreach (BaseTimer basetimer in baseTimerList) { basetimer.RemoveTaskItem(baseDTU); } } }
public void RemoveTaskItem(BaseDTU item) { baseDTUList.Remove(item); }