Example #1
0
 internal QuickTimer(PeriodicTimerWatch objWatch, int nMsTimer, DelegateTimerFired del, string strGuid, ILogInterface logmgr)
 {
     Period      = nMsTimer;
     watch       = objWatch;
     CallBack    = del;
     Id          = Interlocked.Increment(ref BaseTimerId);
     Guid        = strGuid;
     m_logmgr    = logmgr;
     m_bCanceled = false;
 }
Example #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);
        }