public static void SetTimer(delEmpty callback, int time) { MyTimer ttt = new MyTimer(); t.Add(ttt); callbacks.Add(callback); callframes.Add(MyTimer.CurrentFrame); ttt.Interval = time; ttt.Tick += new EventHandler(ttt_Tick); ttt.Start(); }
static void ttt_Tick(object sender, EventArgs e) { search = (MyTimer)sender; int ind = t.FindIndex(Pred); if (callframes[ind] == MyTimer.CurrentFrame) { return; } search.Stop(); callbacks[ind].Invoke(); t.RemoveAt(ind); callbacks.RemoveAt(ind); callframes.RemoveAt(ind); }
static bool Pred(MyTimer q) { return(q == search); }