public void AddAndRemoveWhileEnumerating()
 {
     foreach (int num in list)
     {
         if (num == 5)
         {
             list.Add(7);
         }
         else if (num > 1)
         {
             list.Remove(num);
         }
     }
     Assert.AreEqual("1, 5, 7", list.ToText());
 }
예제 #2
0
파일: Alert.cs 프로젝트: andyhx/xenadmin
        public static void RemoveAlert(Alert a)
        {
            lock (XenCenterAlertsLock)
                XenCenterAlerts.Remove(a);

            log.InfoFormat("Removed {0}: {1} - {2}", a.GetType().Name, a.Title, a.Description);
        }
예제 #3
0
파일: Alert.cs 프로젝트: wranders/xenadmin
 public static void RemoveAlert(Alert a)
 {
     try
     {
         lock (XenCenterAlertsLock)
             XenCenterAlerts.Remove(a);
     }
     catch (Exception e)
     {
         log.Error("Failed to remove alert. ", e);
     }
 }
예제 #4
0
        /// <summary>
        /// Use this method to remove connections from the list. It clears the cache and waits for it to complete before removing the connection.
        /// This ensures that any event handlers that are relying on the remove events get a chance to receive them before being deregistered in
        /// MainWindow on the connection remove event handler.
        /// </summary>
        /// <param name="connection"></param>
        public static void ClearCacheAndRemoveConnection(IXenConnection connection)
        {
            Thread t = new Thread((ThreadStart)
                                  delegate
            {
                connection.Cache.Clear();
                lock (ConnectionsLock)
                {
                    XenConnections.Remove(connection);
                }
            });

            t.IsBackground = true;
            t.Start();
        }