public NzbDownloadManager()
 {
     _servers = new List<NzbServer>();
     _downloads = new List<NzbDownload>();
     _connectionPool = new NzbConnectionPool();
     _downloadQueue = new NzbDownloadQueue(_connectionPool);
     _decoderQueue = new NzbDecoderQueue(4096, 3);
     _isDisposed = false;
     _isDisposedSynchronization = new object();
 }
        public void Dispose()
        {
            lock (_downloadQueue)
            {
                lock (_decoderQueue)
                {
                    lock (_servers)
                    {
                        foreach (var download in this.Downloads)
                        {
                            this.RemoveDownload(download);
                        }

                        _downloadQueue.Dispose();
                        _downloadQueue = null;

                        _decoderQueue.Dispose();
                        _decoderQueue = null;

                        _servers.ForEach(server => server.Connections.ForEach(con => con.Discard()));

                        _servers.Clear();
                        _servers = null;

                        lock (_isDisposedSynchronization)
                        {
                            _isDisposed = true;
                        }
                    }

                }
            }
        }