예제 #1
0
 public void RemoveTimer(QuickTimer timer)
 {
     lock (TimerLock)
     {
         TimerList.Remove(timer);
     }
 }
예제 #2
0
 public void AddTimer(QuickTimer timer)
 {
     lock (TimerLock)
     {
         TimerList.Add(timer);
     }
 }
예제 #3
0
        public void Cancel(QuickTimer timer)
        {
            lock (GlobalWatchesLock)
            {
                if (GlobalWatches.ContainsKey(timer.Period) == true)
                {
                    timer.watch = GlobalWatches[timer.Period];
                    timer.watch.RemoveTimer(timer);

                    /// Remove this watch if we have no one else waiting;
                    if (timer.watch.Count <= 0)
                    {
                        GlobalWatches.Remove(timer.Period);
                        GlobalWatchesSorted.Remove(timer.watch);
                    }
                }
            }
        }
예제 #4
0
        public IMediaTimer CreateTimer(int nMilliseconds, DelegateTimerFired del, string strGuid, ILogInterface logmgr, int nAvgDevMs)
        {
            lock (LockInit)
            {
                if (Initialized == false)
                {
                    PrepareStuff();
                    Initialized = true;
                }
            }

            PeriodicTimerWatch watch = null;

            lock (GlobalWatchesLock)
            {
                if (GlobalWatches.ContainsKey(nMilliseconds) == false)
                {
                    watch = new PeriodicTimerWatch(nMilliseconds);
                    GlobalWatches.Add(nMilliseconds, watch);
                    GlobalWatchesSorted.Add(watch);

                    foreach (PeriodicTimerWatch nextwatch in GlobalWatchesSorted)
                    {
                        nextwatch.LockTimeForSort();
                    }
                    GlobalWatchesSorted.Sort();

                    EventNewTimer.Set();
                }
                else
                {
                    watch = GlobalWatches[nMilliseconds];
                }
            }

            QuickTimer objNewTimer = new QuickTimer(watch, nMilliseconds, del, strGuid, logmgr, nAvgDevMs);

            watch.AddTimer(objNewTimer);

            return(objNewTimer);
        }