public void AddConnection(NzbConnection connection)
        {
            lock (_synchroObject)
            {
                _connectionPool.Enqueue(connection);

                Monitor.Pulse(_synchroObject);
            }
        }
        private void Download(NzbDownloadJob job, NzbConnection connection)
        {
            lock (job.Segment)
            {
                job.Segment.Status = NzbSegmentStatus.Downloading;
            }

            if (connection.Status != NzbConnectionStatus.Connected)
            {
                connection.Connect();
            }

            string downloadedSegment = null;

            try
            {
                downloadedSegment = connection.DownloadSegment(job.Segment);
            }
            catch (NzbSegmentDownloadFailedException)
            {
                lock (job.Segment)
                {
                    job.Segment.Status = NzbSegmentStatus.DownloadFailed;
                    return;
                }
            }

            string tempDirectory = job.TemporaryDirectory;

            if (!Directory.Exists(tempDirectory))
            {
                Directory.CreateDirectory(tempDirectory);
            }

            byte[] rawBytes = Encoding.GetEncoding("iso-8859-1").GetBytes(downloadedSegment);

            string fullPath = Path.Combine(tempDirectory, job.Segment.Id);

            using (FileStream stream = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, rawBytes.Length))
            {
                stream.Write(rawBytes, 0, rawBytes.Length);
                stream.Close();
            }

            lock (job.Segment)
            {
                job.Segment.Status = NzbSegmentStatus.Downloaded;
            }
        }