Example #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;
 }
Example #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;
 }
Example #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;
 }
Example #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;
 }
Example #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;
 }
Example #6
0
        public void Cancel()
        {
            lock (TimerLock)
            {
                if (SortedTimers.Contains(this))
                {
                    SortedTimers.Remove(this);
                    EventNewTimer.Set();
                }
            }

            this.CallBack = null;
        }
Example #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));
        }
Example #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));
         }
     }
 }
Example #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);
        }
Example #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);
        }
Example #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));

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

             this.CallBack = null;
        }
Example #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;
        }