Advertisement
NikolaDimitroff

Async web request

Jul 22nd, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.27 KB | None | 0 0
  1. // Simultaneously
  2. Parallel.ForEach(urls, (url) =>
  3.     {
  4.         Response response = MakeWebRequest(url);
  5.         // Do stuff with the response
  6.     });
  7.  
  8. // One after another
  9. foreach (var url in urls)
  10. {
  11.     Response response = await MakeWebRequestAsync(url);
  12.     // Do stuff with the response
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement