コード例 #1
0
        private void DoRemoveIdleConnections()
        {
            // Removing items from a collection during iteration
            // is not allowed, so we create a clone of the original
            // collection. We then iterate over the clone, but
            // remove items from the original collection
            Hashtable clonedHashtable = pool.Clone() as Hashtable;

            foreach (string hostAddress in clonedHashtable.Keys)
            {
                CoordinatorConnection coordinator = clonedHashtable[hostAddress] as CoordinatorConnection;
                if (coordinator.IsIdle)
                {
                    pool.Remove(hostAddress);
                    coordinator.Disconnect();
                }
            }
        }