public static void SetTimer(Action d, object key, ReenteranceMode rMode, TimeSpan initial, TimeSpan frequency) { TimerEx t = null; lock (timers) { if (timers.ContainsKey(key)) { t = timers[key]; if (d == null) { t.Close(); timers.Remove(key); } else { t.d = d; t.Timer.Change(initial, frequency); t.Mode = rMode; } } else { if (d != null) { t = new TimerEx(d, rMode, initial, frequency); timers.Add(key, t); } } } }