CSharp examples for Thread Asynchronous:Async
Await Inside Try Finally Statement
using System;// w w w. j a va 2 s .c om using System.ComponentModel; using System.Threading.Tasks; class AwaitInsideTryFinally { static async Task AwaitInTryFinally(TimeSpan delay) { Console.WriteLine("Before try block"); try { Console.WriteLine("Before await"); await Task.Delay(delay); Console.WriteLine("After await"); } finally { Console.WriteLine("In finally block"); } Console.WriteLine("After finally block"); } static void Main() { AwaitInTryFinally(TimeSpan.FromSeconds(1)).Wait(); } }