I have a method name DownloadProgressChanged. My program will be able to download multiple things, so therefore it will have different progressbars. The problem with DownloadProgressChanged is that I'm unsure how to get it to use a different progressbar depending on what is being downloaded. So essentially I'm wondering if I can pass the progressBar name through as a parameter when the method is called. (Like if downloading something else, progressBar2 will activate instead of progressBar1). My code is below.
WebClient wc = new WebClient();
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileCompleted);
void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
}