Пример #1
0
        public void Cancel()
        {
            lock (TimerLock)
            {
                if (SortedTimers.Contains(this))
                {
                    SortedTimers.Remove(this);
                    EventNewTimer.Set();
                }
            }

            this.CallBack = null;
        }
Пример #2
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);
        }