public static void AddAlertRange(IEnumerable <Alert> collection) { try { lock (XenCenterAlertsLock) XenCenterAlerts.AddRange(collection); } catch (Exception e) { log.Error("Failed to add incoming alerts", e); } }
public void AddRangeOfElementsWhileEnumerating() { foreach (int num in list) { if (num == 5) { list.AddRange(new[] { 2, 2, 2 }); } } Assert.IsTrue(list.Contains(2)); Assert.IsFalse(list.Contains(4)); Assert.AreEqual(6, list.Count); }