Ejemplo n.º 1
0
        public void UpdateQueue(MegaFileDownload d)
        {
            lock (downloadQueue)
            {
                d.Finished              = true;
                d.ProgressBar.Tag       = null;
                d.ProgressBar.Value     = 0;
                d.ProgressLabel.Visible = false;

                if (downloadQueue.Count > 0 && !cancellationTokenSource.IsCancellationRequested)
                {
                    //if (d.ProgressBar.Tag == null)
                    //{
                    MegaFileDownload newd = downloadQueue.Dequeue();
                    newd.ProgressBar   = d.ProgressBar;
                    newd.ProgressLabel = d.ProgressLabel;
                    newd.StartDownload();
                    //}
                }
                if (finishedDownloads == downloads.Count && !cancellationTokenSource.IsCancellationRequested)
                {
                    DownloadsFinishedForm downloadsFinishedForm = new DownloadsFinishedForm(downloadFolderPath, "All downloads are finished!");
                    downloadsFinishedForm.Show();
                }
            }
            finishedDownloads++;
            progresslabels[progresslabels.Length - 1].Text = $"{finishedDownloads}/{downloads.Count} files finished";
        }
Ejemplo n.º 2
0
 public void Start()
 {
     progresslabels[progresslabels.Length - 1].Text    = "";
     progresslabels[progresslabels.Length - 1].Visible = true;
     lock (downloadQueue)
     {
         if (downloadQueue.Count > 0)
         {
             for (int i = 0; i < progressbars.Length; i++)
             {
                 if (progressbars[i].Tag == null)
                 {
                     MegaFileDownload dd = downloadQueue.Dequeue();
                     dd.ProgressBar   = progressbars[i];
                     dd.ProgressLabel = progresslabels[i];
                     dd.StartDownload();
                     if (downloadQueue.Count == 0)
                     {
                         break;
                     }
                 }
             }
         }
     }
 }