Usually nothing is upstairs. The whole point of the state machine that you describe is that when the async action completes, it makes a callback to the state machine method MoveNext
(the name is a legacy of the operator yield
, which is essentially a primitive predecessor of async
semantics). This process is not actually call-based, it is more like an event making a callback for your method (in this case, the method MoveNext
created by the compiler).
, , "". , "". , . MoveNext
, - "".
:
static async void Main()
{
Console.WriteLine(await A());
}
static async Task<int> A()
{
return await B();
}
static async Task<int> B()
{
await Task.Delay(1);
return 1;
}
Main
? Main
async
, , . , async
-. # 7.1 async
.
, Main
A
? A
B
. B
. async
, callstack . B
A
. A
Main
. , Main
, A
, 1
.