public void AddDownload(NzbDownload download, string downloadDirectory, string temporaryDirectory)
        {
            ArgumentChecker.ThrowIfNull("download", download);
            ArgumentChecker.ThrowIfNullOrWhitespace("downloadDirectory", downloadDirectory);
            ArgumentChecker.ThrowIfNullOrWhitespace("temporaryDirectory", temporaryDirectory);

            lock (download)
            {
                string downloadFullpath = Path.Combine(downloadDirectory, download.DownloadDirectory);

                foreach (var currentPart in download.Parts)
                {
                    foreach (var currentSegment in currentPart.Segments)
                    {
                        var job = new NzbDownloadJob(downloadFullpath, temporaryDirectory, currentSegment, SegmentDownloadedCheckpoint);

                        _downloadQueue.EnqueueJob(job);
                    }
                }
            }

            lock (_downloads)
            {
                _downloads.Add(download);
            }
        }
        private void SegmentDownloadedCheckpoint(NzbDownloadJob downloadJob)
        {
            lock (_isDisposedSynchronization)
            {
                if (_isDisposed)
                {
                    return;
                }
            }

            var downloadedSegment = downloadJob.Segment;

            lock (downloadedSegment.Parent)
            {
                var parent = downloadedSegment.Parent;
                var numberOfSuccessfullyDownloadedSegments = parent.Segments.Where(seg => seg.Status == NzbSegmentStatus.Downloaded).Count();

                if (parent.Segments.Count == numberOfSuccessfullyDownloadedSegments)
                {
                    parent.Status = NzbPartStatus.Downloaded;

                    var job = new NzbDecoderJob(downloadJob.TemporaryDirectory, downloadJob.DownloadDirectory, downloadedSegment.Parent, Encoding.GetEncoding("iso-8859-1"), PartDecodedCheckpoint);

                    _decoderQueue.EnqueueJob(job);
                }
            }
        }