If I have an async method :
public async Task MyMethodAsync()
{
// [.. Some synchronous code here ..]
await AnotherAsyncMethod();
}
And at some point in my code I call it like that :
await MyMethodAsync();
Will this statement immediately return to the caller without even entering the MyMehodAsync ? I guess so but not sure.
If I want the call to MyMethodAsync to first execute the [.. Some synchronous code here ..] part immediately, should I rather do :
var t = MyMethodAsync();
await t;
Thanks
will execute synchronously until the first await yields control. You’re doing it right. Your last example is exactly the same as your previous in terms of what gets executed synchronously.