示例#1
0
        public int CompareTo(object obj)
        {
            MediaTimer objTimer2 = obj as MediaTimer;

            if (obj == null)
            {
                return(0);
            }
            return(DueTime.CompareTo(objTimer2.DueTime));
        }
示例#2
0
        private static void AddSorted(MediaTimer objTimer)
        {
            lock (TimerLock)
            {
                int nIndexInsert = 0;
                foreach (MediaTimer nextTimer in SortedTimers)
                {
                    if (objTimer.CompareTo(nextTimer) < 0) // this timer is less than this timer, insert here
                    {
                        break;
                    }
                    nIndexInsert++;
                }

                SortedTimers.Insert(nIndexInsert, objTimer);
                EventNewTimer.Set();
            }
        }
示例#3
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);
        }
示例#4
0
        private static void AddSorted(MediaTimer objTimer)
        {
            lock (TimerLock)
             {
            int nIndexInsert = 0;
            foreach (MediaTimer nextTimer in SortedTimers)
            {
               if (objTimer.CompareTo(nextTimer) < 0) // this timer is less than this timer, insert here
               {
                  break;
               }
               nIndexInsert++;
            }

            SortedTimers.Insert(nIndexInsert, objTimer);
            EventNewTimer.Set();
             }
        }
示例#5
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;
        }