public ScheduledEvent(string id, DateTime time, ScheduledEventHandler handler) { this.id = id; this.Handler = handler; timer = new Timer(new TimerCallback(Callback), null, 10000, 0); NextCall = time; }
public static string ScheduleEvent(DateTime time, ScheduledEventHandler handler) { string id; lock (map) { do { id = random.Next(10000000, 100000000).ToString(); } while (map[id] != null); } ScheduleEvent(id, time, handler); return(id); }
public static void ScheduleEvent(string id, DateTime time, ScheduledEventHandler handler) { lock (map) { ScheduledEvent ev = (ScheduledEvent)map[id]; if (ev == null) { Debug.WriteLine("Scheduling event " + id + " for " + time.ToShortTimeString()); ev = new ScheduledEvent(id, time, handler); } else { Debug.WriteLine("Rescheduling event " + id + " for " + time.ToShortTimeString()); if (handler != null) { ev.Handler = handler; } ev.NextCall = time; } map[id] = ev; } }
protected void scheduleOnce(double at, double delay, ScheduledEventHandler handler) { timeouts.Add(new Timeout(false, at + delay, handler)); }
public Timeout(bool r, double t, ScheduledEventHandler h) { repeat = r; timeoutAt = t; handler = h; }