foreach (string line in textBox3.Lines)
{
int pos = line.IndexOf("?v=");
string videoid = line.Substring(pos + 3, 11);
GetFile(videoid);
}
GetFile() {
...code
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri(fileRequest), @textBox2.Text + @"\" + title + ".mp3");
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
Question is how to hadle one progressbar and many webclients? This scenario doesn’t work, because every client is updating bar on it’s own and it’s going crazy, so what’s the proper way? PS. I cannot use just one WebClient, I’m making requests before for every file.
I’d imagine you could do something like this: