示例#1
0
 private MediaTimer(System.DateTime dtDue, DelegateTimerFired del, string strGuid, ILogInterface logmgr)
 {
     DueTime  = dtDue;
     CallBack = del;
     Id       = Interlocked.Increment(ref BaseTimerId);
     Guid     = strGuid;
     m_logmgr = logmgr;
 }
示例#2
0
 private MediaTimer(System.DateTime dtDue, DelegateTimerFired del, string strGuid, ILogInterface logmgr)
 {
     DueTime = dtDue;
      CallBack = del;
      Id = Interlocked.Increment(ref BaseTimerId);
      Guid = strGuid;
      m_logmgr = logmgr;
 }
示例#3
0
 private MediaTimer(System.DateTime dtDue, DelegateTimerFired del, string strGuid, object objTag)
 {
     DueTime  = dtDue;
     CallBack = del;
     Id       = Interlocked.Increment(ref BaseTimerId);
     Guid     = strGuid;
     m_logmgr = null;
     Tag      = objTag;
 }
示例#4
0
 private MediaTimer(System.DateTime dtDue, DelegateTimerFired del, string strGuid, object objTag)
 {
     DueTime = dtDue;
      CallBack = del;
      Id = Interlocked.Increment(ref BaseTimerId);
      Guid = strGuid;
      m_logmgr = null;
      Tag = objTag;
 }
示例#5
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;
 }
示例#6
0
        public void Cancel()
        {
            lock (TimerLock)
            {
                if (SortedTimers.Contains(this))
                {
                    SortedTimers.Remove(this);
                    EventNewTimer.Set();
                }
            }

            this.CallBack = null;
        }
示例#7
0
        public static IMediaTimer CreateTimer(int nMilliseconds, DelegateTimerFired del, string strGuid, ILogInterface logmgr, int nAvgDevMs)
        {
            int nIndex = 0;

            lock (LockCurrentTimerThread)
            {
                CurrentTimerThread++;
                if (CurrentTimerThread > (Timers.Count - 1))
                {
                    CurrentTimerThread = 0;
                }
                nIndex = CurrentTimerThread;
            }
            return(Timers[nIndex].CreateTimer(nMilliseconds, del, strGuid, logmgr, nAvgDevMs));
        }
示例#8
0
 public void Fire()
 {
     try
     {
         if (CallBack != null)
         {
             CallBack.DynamicInvoke(new object[] { this }); //invoke our self if we have no host
             CallBack = null;
         }
     }
     catch (System.NullReferenceException e)
     {
         if (m_logmgr != null)
         {
             m_logmgr.LogError(Guid, MessageImportance.Highest, string.Format("Exception in timer thread: {0}", e));
         }
     }
 }
示例#9
0
        public static IMediaTimer CreateTimer(int nMilliseconds, DelegateTimerFired del, string strGuid, object objTag)
        {
            lock (LockInit)
            {
                if (Initialized == false)
                {
                    PrepareStuff();
                    Initialized = true;
                }
            }

            System.DateTime dtDue = DateTime.Now.AddMilliseconds(Convert.ToDouble(nMilliseconds));

            MediaTimer objNewTimer = new MediaTimer(dtDue, del, strGuid, objTag);

            AddSorted(objNewTimer);

            return(objNewTimer);
        }
示例#10
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);
        }
示例#11
0
        public void Fire()
        {
            try
             {
            if (CallBack != null)
            {
               CallBack.DynamicInvoke(new object[] { this }); //invoke our self if we have no host
               CallBack = null;
            }
             }
             catch (System.NullReferenceException e)
             {
            if (m_logmgr != null)
               m_logmgr.LogError(Guid, MessageImportance.Highest, string.Format("Exception in timer thread: {0}", e));

             }
        }
示例#12
0
        public void Cancel()
        {
            lock (TimerLock)
             {
            if (SortedTimers.Contains(this))
            {
               SortedTimers.Remove(this);
               EventNewTimer.Set();
            }
             }

             this.CallBack = null;
        }
示例#13
0
        public static IMediaTimer CreateTimer(int nMilliseconds, DelegateTimerFired del, string strGuid, object objTag)
        {
            lock (LockInit)
             {
            if (Initialized == false)
            {
               PrepareStuff();
               Initialized = true;
            }
             }

             System.DateTime dtDue = DateTime.Now.AddMilliseconds(Convert.ToDouble(nMilliseconds));

             MediaTimer objNewTimer = new MediaTimer(dtDue, del, strGuid, objTag);
             AddSorted(objNewTimer);

             return objNewTimer;
        }