Dowloading a bunch of files asynchronous wait till last finished

Posted by Casper Broeren on Stack Overflow See other posts from Stack Overflow or by Casper Broeren
Published on 2010-06-14T15:32:41Z Indexed on 2010/06/14 15:52 UTC
Read the original article Hit count: 171

Filed under:
|
|
|

I'm trying to download a lot of files after downloading a sql statement must insert a record. I'm using System.Net.Client to download each file synchronously, still it could be done asynchronous. There's no relation or dependency between each download.

At first I just tried to use WebClient.DownloadFileAsync but that shutted the program down and killed all the download processes/threads. Second I tried to create a wait routine something like this;

while (processedFiles < totalFiles)
         Thread.Sleep(1000)

This freezed everything. So could someone tell me which aproach to take to implement this Async?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about asynchronous