The WebClient.DownloadFileAsync
method only supports one active request per WebClient
instance, so you'd have to either wait for the previous request to complete before initiating the next request, or you'd need to use one WebClient
instance per request. DownloadFileAsync
is non-blocking, so it'll schedule the request & notify consumers by firing the WebClient.DownloadFileCompleted
event once it's finished.
There's a similar version of this method WebClient.DownloadFileTaskAsync
that returns a Task
, so you could go through your loop calling this method, adding each Task
to a collection, then calling Task.WhenAll
after the loop, which you can use to wait for all your file downloads to complete.
The question is if you have all file downloads occurring simultaneously, but you only have one progress bar, how should the progress be updated? If all file downloads update the same progress bar with their progress they'll all just be overwriting each other's progress.
You could show multiple progress bars, although that's not the most scalable solution, so would you expect the progress bar to reflect the total progress across all requests?