private void NotifyClientsTime(object source, ElapsedEventArgs e) { foreach (KeyValuePair <int, IAlert> pair in clients) { IAlert client = pair.Value; try { client.OnAlert(DateTime.Now); } catch (Exception) { clients.Remove(pair.Key); } } }
public void Clone() { Console.WriteLine("Clone start " + clients.Count); int counter = 0; int size = clients.Count; foreach (KeyValuePair <int, IAlert> pair in clients) { if (counter >= size) { break; } IAlert client = pair.Value; try { client.OnAlert(DateTime.MinValue); } catch (Exception) { } counter++; } Console.WriteLine("End of cloning " + clients.Count); }