34
1
using System;
2
using System.Net;
3
using System.Threading.Tasks;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
10
Task.Factory.StartNew(() => VisitPage());
11
12
}
13
14
private async static void VisitPage()
15
{
16
try
17
{
18
var client = new WebClient();
19
string data = await client.DownloadStringTaskAsync("Www.google.com");
20
21
22
}
23
catch(Exception ex)
24
{
25
await LogErrorAsync();
26
}
27
}
28
29
30
private static Task LogErrorAsync()
31
{
32
return Task.Factory.StartNew(() => { Console.WriteLine("Error Occured");});
33
}
34
}
Cached Result
42
666
666