コード例 #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
ファイル: MediaTimer.cs プロジェクト: Hitchhikrr/Voip
 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
ファイル: MediaTimer.cs プロジェクト: Hitchhikrr/Voip
 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
ファイル: MediaTimer.cs プロジェクト: Hitchhikrr/Voip
        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
ファイル: MediaTimer.cs プロジェクト: Hitchhikrr/Voip
        public void Cancel()
        {
            lock (TimerLock)
             {
            if (SortedTimers.Contains(this))
            {
               SortedTimers.Remove(this);
               EventNewTimer.Set();
            }
             }

             this.CallBack = null;
        }
コード例 #13
0
ファイル: MediaTimer.cs プロジェクト: Hitchhikrr/Voip
        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;
        }