public void Remove(ThreadTimer timer) { lock (this) { int i = 0; for (; i < tickQueue.Count; ++i) { if (tickQueue[i].Timer == timer) { break; } } if (i < tickQueue.Count) { tickQueue.RemoveAt(i); } Monitor.PulseAll(this); } }
public void Add(ThreadTimer timer) { lock (this) { var tick = new Tick { Timer = timer, Time = watch.Elapsed }; tickQueue.Add(tick); tickQueue.Sort(); if (loop == null) { loop = new Thread(TimerLoop); loop.Start(); } Monitor.PulseAll(this); } }