Task.Run(() => { Console.WriteLine("This code is running asynchronously."); });
async TaskThis example defines an asynchronous method, GetMessageLengthAsync, which uses the WebClient class to download the contents of a web page. The method is marked as async and returns a TaskGetMessageLengthAsync(string message) { WebClient client = new WebClient(); string result = await client.DownloadStringTaskAsync("http://www.example.com"); return result.Length; }