We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Jagdish • 1 year ago

Hi AramT,
I am sorry but I am confused here...
In the above article, you wrote: and if you do not include the keyword await, then the method will be treated as a normal or synchronous method.
But as per my believe, when we have to make any asynchronous method (declared as async) synchronous then we call it using 'await'. i.e. if method ABC is declared with async then the call "ABC();" would be asynchronous and "await ABC();" would then act as synchronous. If possible can you please put some light on it?

Yogi • 1 year ago

I think the keyword await inside a method marked as async causes the next statement after the await to not execute until the statement marked with await has been completed. Once completed, the subsequent statements will proceed until it encounters another await, if any. The method marked as async itself can be called with or without await, depending on our intention. If we want the subsequent statements to wait for the completion of async, we should put await in front of the call. Otherwise, we can just all the async method without await keyword and all the subsequent statements will execute right away before the async method finishes its task. Either way it is non blocking. The thread will still be available to process other things, it just would not process the subsequent statements immediately following the await keyword until it encounters the end of the code block.

AramT, this is an excellent article, providing easy-to-understand explanation. And your sample code is awesome. Thank you for the inspiration!

BlackMariah • 1 year ago

Very nice read! I do have a question though. since .Wait() is blocking code, how do I proceed with it, when I have a very long operation? Doesn't wait block my main thread then and prevents further execution of code, which would give litle benefit to simply doing stud synchronously?

Nathan Barnard • 10 months ago

Use await in conjunction with Task.Run and put it on the thread pool if it is CPU-bound work and you don't want it to be blocking.

Cipher Coder • 1 year ago

First Time seeing such a detailed article on async await.. Thanks a lot

Anonymous • 1 year ago

Excellent article & examples. Thank you!

Terrible arcticle... This article does not explain the principles of work.

Anonymous • 1 year ago

This is a great article explaining how async/await in c# 5. His explanation is cleared & as straightforward as you can get. Are you an entry or a junior developer?