fork download
  1. using System;
  2. using System.Net;
  3. using System.Threading.Tasks;
  4.  
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. var s = GetFile("http://u...content-available-to-author-only...p.net/");
  10.  
  11. Console.WriteLine(s.Result);
  12. }
  13.  
  14. static Task<string> GetFile(string url)
  15. {
  16. var tcs = new TaskCompletionSource<string>();
  17.  
  18. var wc = new WebClient();
  19.  
  20. wc.DownloadStringCompleted += (sender, e) =>
  21. {
  22. if (e.Error != null)
  23. tcs.TrySetException(e.Error);
  24. else if (e.Cancelled)
  25. tcs.TrySetCanceled();
  26. else
  27. tcs.TrySetResult(e.Result);
  28. wc.Dispose();
  29. };
  30.  
  31. wc.DownloadStringAsync(new Uri(url));
  32.  
  33. return tcs.Task;
  34. }
  35. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty