0

Suppose thread A use 'await' to wait for something to finish on thread B. while B is busy with the workload, A is considered to have been marked with a 'suspension point'. And the execution flow in A will continue with the 'caller' method of the suspended code block. When B is done, it will notify A to continue from the suspension point.

My questions are:

  • What is the content of the context info kept for the suspension point?

  • How is the context info be stored?

  • How does B notify A about it's completion?

  • How is the context info of A restored? (I think once the context info for A is restored, A will resume from the suspension point 'naturally')

  • What's the effect of 'async' and 'await' on compiler, respectively. In other words, what special work does the compiler do behind the curtain.

1 Answer 1

3

First, forget threads. async and await have very little to do with threading and much more to do with rewriting methods so you can use continuation passing style more easily.

I recommend you read my async/await intro post and then follow up with the MSDN documentation (which is quite good). That would answer all your questions except the last one, which is best answered by Jon Skeet's eduasync blog series.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the referencing materials, due to the time limit, i have only read only a few materials so far. I will spend some time reading the links.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.