Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8057979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:12:29+00:00 2026-06-05T09:12:29+00:00

I´m currently trying to add parallel downloads to my application but I don´t know

  • 0

I´m currently trying to add parallel downloads to my application but I don´t know how to handle the DownloadProgressChangedEvent to display the progress in multiple progressbars.

I´m using a datagridview with predefined rows for each file the user is able to download and each row has a cell with a progressbar in it.

The problem now is, that I don´t know how to update each progressbar individually, because right now, all selected progressbars are showing the same percentage and they´re just jumping between the progress of download1 & download2.

Here´s the code im using:

To start the downloads:

private void download_button_Click(object sender, EventArgs e)
    {
        start = DateTime.Now;
        download_button.Enabled = false;

        Rows = dataGridView1.Rows.Count;
        Checked = 0;

        CheckedCount = 0;

            //count the selected rows
            for (i = 0; i < Rows; i++)
            {
                Checked = Convert.ToInt32(dataGridView1.Rows[i].Cells["checkboxcol"].FormattedValue);

                CheckedCount += Checked;

                richTextBox3.Text = CheckedCount.ToString();
            }


        for (int z = 1; z < CheckedCount; z++)
        {             
            _MultipleWebClients = new WebClient();

            _MultipleWebClients.DownloadFileCompleted += new AsyncCompletedEventHandler(_DownloadFileCompleted);
            _MultipleWebClients.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(_DownloadProgressChanged);
            _MultipleWebClients.DownloadFileAsync(new Uri(_downloadUrlList[z].ToString()), @"F:\test" + z + ".mp4");     
        }

    }

(I´m also unable to download more than two files simultaneously – the third download won´t start until the first two are finished)


DownloadProgressChangedEvent:

    private void _DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        progressBar1.Value = e.ProgressPercentage;
        for (int c = 0; c < CheckedCount; c++)
        {
            dataGridView1.Rows[_downloadRowNrList[c]].Cells[3].Value = e.ProgressPercentage;
        }

        float size = ((e.TotalBytesToReceive / 1024) / 1024);
        label1.Text = size.ToString();

        double dn = (double)e.BytesReceived / 1024.0 / (DateTime.Now - start).TotalSeconds;
        label2.Text = (dn.ToString("n") + " KB/s) " + e.ProgressPercentage);        
    }

The problem probably is, that all progressbars are using the same DownloadProgressChangedEvent, but I´m not sure how to create multiple of these events without knowing the needed number…

So i hope that someone is able to help me with this,

thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:12:31+00:00Added an answer on June 5, 2026 at 9:12 am

    What you want to do is use the other DownloadFileAsync method:
    http://msdn.microsoft.com/en-us/library/ms144197.aspx

    The third parameter is a userToken which gets passed as part of the DownloadProgressChangedEventArgs (it’s in the UserState property).

    So, when you make the DownloadFileAsync call, pass in a unique token (an integer, or something else) that you can then associate with the progressBar that needs updating.

        //(Snip)
    
        //in download_button_Click, pass the row you are updating to the event.
        for (int z = 1; z < CheckedCount; z++)
        {             
            _MultipleWebClients = new WebClient();
    
            _MultipleWebClients.DownloadFileCompleted += new AsyncCompletedEventHandler(_DownloadFileCompleted);
            _MultipleWebClients.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(_DownloadProgressChanged);
            _MultipleWebClients.DownloadFileAsync(new Uri(_downloadUrlList[z].ToString()), @"F:\test" + z + ".mp4", dataGridView1.Rows[z]);     
        }
    }
    
    private void _DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        var rowToUpdate = (DataGridViewRow)e.UserState;
        RowToUpdate["ProgressBar"].Value = e.ProgressPercentage;
        RowToUpdate["TextProgress"].Value = e.ProgressPercentage;
        RowToUpdate["BytesToRecive"].Value = ((e.TotalBytesToReceive / 1024) / 1024).ToString();
    
        double dn = (double)e.BytesReceived / 1024.0 / (DateTime.Now - start).TotalSeconds;
        RowToUpdate["Speed"].Value = (dn.ToString("n") + " KB/s) " + e.ProgressPercentage);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to add a a settings into my application but I
I am currently trying to add a widget to my application and have been
Im currently trying to add the SlidingDrawer in my application.. My activity consists GridView
Im currently trying to add some Style to my Hyperlinkbutton, but cannot get it
Currently trying at add ajax to a site, after much reading I discovered that
I'm currently trying to add PGP signing support to my small e-mail sending script
I'm currently trying to add an MSChart to a partial view in ASP.NET MVC
I am currently trying to add a JavaScript confirm message when a user attempts
So currently I am trying to add a feature to a userscript I have
I'm currently trying to implement a simple Add-In for InfoPath 2010 Filler/Editor mode, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.