Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Created April 29, 2012 00:49
Show Gist options
  • Save alexsandro-xpt/2522945 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/2522945 to your computer and use it in GitHub Desktop.
Async CTP exemplo 1
public async Task<int> SumPageSizesAsync(IList<Uri> uris) {
int total = 0;
int i = 0;
int n = 0;
foreach (var uri in uris) {
Console.WriteLine("{0} - {1}", ++n, DateTime.Now.ToString("yyyyMMddHHmmssffff"));
Console.WriteLine(string.Format("{0} Found {1} bytes ...", ++i, total));
var wc = new WebClient();
var data = await wc.DownloadDataTaskAsync(uri);
Console.WriteLine("{0} - {1}", n, DateTime.Now.ToString("yyyyMMddHHmmssffff"));
total += data.Length;
}
Console.WriteLine(string.Format("Found {0} bytes total", total));
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment