CSharp examples for Thread Asynchronous:Task
Await Completed Task
using System;/*w w w.j ava 2s . c o m*/ using System.ComponentModel; using System.Threading.Tasks; class AwaitCompletedTask { static void Main() { Task task = DemoCompletedAsync(); Console.WriteLine("Method returned"); // Safe in a console app - no synchronization context task.Wait(); Console.WriteLine("Task completed"); } static async Task DemoCompletedAsync() { Console.WriteLine("Before first await"); await Task.FromResult(10); Console.WriteLine("Between awaits"); await Task.Delay(1000); Console.WriteLine("After second await"); } }