Async/await not reacting as expected in Console App

If you had to use an await call in a .net Console app, you would definitely notice that the await is simply skipped over. This is because await only ensure that the rest of the code in the current async method does not execute until the awaited function is completed. However, this does not apply to the caller. For more info, refer to the post from Theo Yaung on stackoverflow.

The way to overcome this issue is to implement it as below.

Task.Run(async () =>


//do any async call here var result = await ...;


This entry was posted in C#, Console and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s