public int CompareTo(object obj) { MediaTimer objTimer2 = obj as MediaTimer; if (obj == null) { return(0); } return(DueTime.CompareTo(objTimer2.DueTime)); }
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(); } }
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); }
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; }