Asymchronism can be obtained through a state machine since it just needs to ensure that no waiting occurs while it is doing something potentially time consuming, so it needs to exchange the execution context between more than one part of the application.
This is an old and well-known technique used in many problems. She will exchange one or more certain states according to what goes on in something related to what she is controlling.
Even this mechanism has several ways to implement it. The way the input that causes state change can be obtained in several ways. An event system indicating the change of state is quite common.
The image there on the question is very illustrative how complicated it is to control the flow of execution. Follow the Indian war.
Wikipedia article.
An implementation in C#.
Detailed explanation of how async/await
c# works. There are more or less examples of how code actually looks when this mechanism is used. Everything there is a state machine, and what is waiting is responsible for changing the state of that machine. When there is no more expect a different processing runs by terminating what has started, but does not block the execution of other things. There is a control whether you can still perform something else, or whether you should resume processing what is on hold.
A example of actual code that is generated by the compiler. Simple, no?
I’m still gonna get better.
Related: What is the difference between a state (State Machine) and a class?
– Taisbevalle
Related: In which context the state machine pattern is indicated?
– Piovezan