What is Async Await in AspNet 6 (C-Sharp)



Understanding Async Await in AspNet 6

1. After playing with Async Await in Asp.net Application I found that when you use Await on a function, it waits until that function completes executing, I know what you are thinking, this sounds like the exact opposite from what the documentation states? Yes, at least to my experience.

I tested this theory using Microsoft Asp.Net Channels API and try to await for a Channel.WriteAsync() function then move on to Await the Channel.ReadAsync().
What I found was that the Await Channels.WriteAsync() function blocked the Main Thread even when I indicated to the function to run in the background.

e.g. Await Channel.WriteAsync().ConfigureAwait(false);//This function call blocked the UI Thread resulting in no rendering until it finished executing
       Await Channel.ReadAsync().ConfigureAwait(false);//This function call did not execute until the Channel.WriteAsync() completed writing

Best Solution:
I also found out that if you want the UI Thread to go on rendering the UI or Page while the Channel.WriteAsync() and Channel.ReadAsync() executed in the background then prifix you code by:

_= Channel.WriteAsync().ConfigureAwait(false);
_= Channel.ReadAsync().ConfigureAwait(false);