private async void cd_Completed(object sender, EventArgs e)
        {
            if (Info.ContentSize < 1)
            {
                Status = HttpDownloaderStatus.MergingFiles;
                Directory.CreateDirectory(SaveDir);
                File.Delete(this.FilePath);
                File.Move(Ranges[0].FilePath, this.FilePath);
                Progress = 100;
                Status   = HttpDownloaderStatus.Completed;
                Completed.Raise(this, EventArgs.Empty, aop);
            }
            else if (Ranges.All(x => x.IsDownloaded) &&
                     Ranges.All(x => x.IsIdle) &&
                     TotalBytesReceived == Info.ContentSize &&
                     !flagMerged)
            {
                Directory.CreateDirectory(SaveDir);
                flagMerged = true;
                Progress   = 100;
                Status     = HttpDownloaderStatus.MergingFiles;
                await MergePartialFiles();

                ProgressChanged.Raise(this, new ProgressChangedEventArgs(Progress), aop);
                Status = HttpDownloaderStatus.Completed;
                Completed.Raise(this, EventArgs.Empty, aop);
            }
            else
            {
                createNewThreadIfRequired();
            }
        }
 private void cd_Stopped(object sender, EventArgs e)
 {
     if (Ranges.All(x => x.IsIdle))
     {
         LastTry = DateTime.Now;
         stopTimer.Stop();
         Status = HttpDownloaderStatus.Stopped;
         Stopped.Raise(this, EventArgs.Empty, aop);
     }
 }
 /// <summary>
 /// Stops all threads, to ensure stopping; wait for Stopped event
 /// </summary>
 public void Stop()
 {
     FlagStop = true;
     stp.Stop();
     if (Ranges.All(x => x.IsIdle))
     {
         Stopped.Raise(this, EventArgs.Empty, aop);
     }
     else
     {
         stopTimer.Start();
     }
 }