Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
        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);
            }
        }