Inheritance: ManagerBase, IThisLock
        protected override void Dispose(bool disposing)
        {
            if (_disposed) return;
            _disposed = true;

            if (disposing)
            {
                _blockUploadedEventQueue.Dispose();

                if (_refreshTimer != null)
                {
                    try
                    {
                        _refreshTimer.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _refreshTimer = null;
                }

                if (_mediateTimer != null)
                {
                    try
                    {
                        _mediateTimer.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _mediateTimer = null;
                }

                if (_reduceTimer != null)
                {
                    try
                    {
                        _reduceTimer.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _reduceTimer = null;
                }

                if (_packetControlManager != null)
                {
                    try
                    {
                        _packetControlManager.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _packetControlManager = null;
                }

                if (_bandwidthLimit != null)
                {
                    try
                    {
                        _bandwidthLimit.Dispose();
                    }
                    catch (Exception)
                    {

                    }

                    _bandwidthLimit = null;
                }
            }
        }
        //#endif
        public ConnectionsManager(ClientManager clientManager, ServerManager serverManager, CacheManager cacheManager, BufferManager bufferManager)
        {
            _clientManager = clientManager;
            _serverManager = serverManager;
            _cacheManager = cacheManager;
            _bufferManager = bufferManager;

            _settings = new Settings();

            _routeTable = new Kademlia<Node>(256, 20);

            _connectionManagers = new LockedList<ConnectionManager>();

            _packetControlManager = new PacketControlManager();
            _packetControlManager.GetLockNodesEvent = (object sender) =>
            {
                lock (_thisLock)
                {
                    return _connectionManagers.Select(n => n.Node).ToArray();
                }
            };

            _creatingNodes = new LockedList<Node>();

            _waitingNodes = new VolatileHashSet<Node>(new TimeSpan(0, 0, 30));
            _removeNodes = new VolatileHashSet<Node>(new TimeSpan(0, 30, 0));

            _succeededUris = new VolatileHashSet<string>(new TimeSpan(1, 0, 0));

            _downloadBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));

            _pushBroadcastMetadatasRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushUnicastMetadatasRequestList = new VolatileHashSet<string>(new TimeSpan(0, 3, 0));
            _pushMulticastMetadatasRequestList = new VolatileHashSet<Tag>(new TimeSpan(0, 3, 0));

            _relayBlocks = new VolatileHashSet<Key>(new TimeSpan(0, 30, 0));

            _refreshTimer = new WatchTimer(this.RefreshTimer, new TimeSpan(0, 0, 5));
            _mediateTimer = new WatchTimer(this.MediateTimer, new TimeSpan(0, 1, 0));
            _reduceTimer = new WatchTimer(this.ReduceTimer, new TimeSpan(0, 3, 0));
        }