System.Threading.Timer.Scheduler.Add C# (CSharp) Method

Add() static private method

static private Add ( Timer timer ) : void
timer Timer
return void
			void Add (Timer timer)
			{
				// Make sure there are no collisions (10000 ticks == 1ms, so we should be safe here)
				// Do not use list.IndexOfKey here. See bug #648130
				int idx = FindByDueTime (timer.next_run);
				if (idx != -1) {
					bool up = (Int64.MaxValue - timer.next_run) > 20000 ? true : false;
					while (true) {
						idx++;
						if (up)
							timer.next_run++;
						else
							timer.next_run--;

						if (idx >= list.Count)
							break;
						Timer t2 = (Timer) list.GetByIndex (idx);
						if (t2.next_run != timer.next_run)
							break;
					}
				}
				list.Add (timer, timer);
				//PrintList ();
			}