Javatpoint Logo
Javatpoint Logo

C# await in catch/finally blocks

C# await is a keyword. It is used to suspend execution of the method until the awaited task is complete.

In C# 6.0, Microsoft added a new feature that allows us to use await inside the catch or finally block. So, we can perform asynchronous tasks while exception is occurred.

Let's see an example. Here, we are calling an asynchronous method inside the catch block.

C# await in Catch Block Example

Output

Array Exception Occurred

We can also use await inside the finally block. Let's see an example.

C# await in finally block example

Output

Array Exception Occurred
Resources has been released






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA