So here is the scenario:
static async void Main(string[] args)
{
await AnAsyncMethod();
}
private static async task<bool> AnAsyncMethod()
{
var x = await someAsyncMethod();
var y = await someOtherAsyncMethod();
return x == y;
}
Is "someAsyncMethod" and "someOtherAsyncMethod" running synchronously because we are using await, or are they both running asynchronously in the order that they are being executed?
UPDATE
Given the answer below stating that the awaited async methods will run sequentially, what would be the purpose of making those method calls asynchronous in the first place if we are just going to stop execution and wait the those method's return values? I have seen native apps in the past use await/async as a means to free up the UI thread, but are there any other reasons why this design would be desirable?
Main
cannot useawait
as its not itself marked asasync
what would be the purpose of making those method calls asynchronous in the first place
I wish more people were asking that... Maybe you'll like my standard posts on when to use async IO and why: stackoverflow.com/a/25087273/122718 Why does the EF 6 tutorial use asychronous calls? stackoverflow.com/a/12796711/122718 Should we switch to use async I/O by default?