Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:11:25+00:00 2026-06-17T19:11:25+00:00

I have a setup as follows: class mytype { Awaiter GetAwaiter() { … }

  • 0

I have a setup as follows:

class mytype
{
   Awaiter GetAwaiter() { ... }
}

class Awaiter : INotifyCompletion
{
  bool IsCompleted { get { return false; } }
  void GetResult () { }

  void OnCompleted(Action continuation)
  {
    //that's the continuation in focus
  }
}

//somewhere else:
async Task MyMethod()
{
  //here instructions for 1st state 
  await new mytype();
  //here instructions for 2nd state 
  await new mytype();
  //here instructions for 3rd state 
}

Am I mistaken, or is the delegate I get from the CLR (within the same method) always more or less the same delegate yet the instance I’m awaiting is different? The C# compiler translates the MyMethod because of the async keyword to a FSM with 3 states. And everytime I await something in that method in C#, internally the MoveNext-Method of the FSM is called. But the FSM keeps track of the states itself, so it knows the last state it was in, so it can proceed to the next state (and execute the instructions associated with the new state).

So essentially I understand that an Invoke of the delegate named continuation internally comes down to the call of the MoveNext-method of the appropriate FSM-Type. Seems like no big magic – or am I mistaken?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:11:26+00:00Added an answer on June 17, 2026 at 7:11 pm

    Yeah, your understand is right. The “big magic” happens when the compiler has to rewrite MyMethod() into the state machine, not during runtime.

    For some more information about how the state machine looks like and how it works, read Jon Skeet’s article Generated code from a simple async method from his Eduasync series. That article describes the code generated by one of the Async CTPs, followup articles address changes since then: Changes between the Async CTP and the Visual Studio 11 Preview and Changes between the VS11 Preview and the Visual Studio 11 Beta.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Pjs sketch, which looks as follows: void setup(){ //setup stuff among
I have this many-many DataMapper/MySQL setup with Torrent and Tag, as follows: class Torrent
I have a page setup as follows <div class="Header"> Header content </div> <div class="Content">
I have a class setup as follows: var oTest = new TEST(); function TEST()
I have a DIV class setup as follows: div.map_view{ height: 420px; transition: height 2s;
Let's say I have a STI setup as follows: class User < ActiveRecord::Base scope
I have a custom initializer setup as follows: public class PromptIfChangesNeededDBInitializer : IDatabaseInitializer<MeyerREContext> {
I have some models setup as follows: public class Form { public int FormId
I have two classes set up as follows: class Point { protected: double coords[3];
Our setup as follows: We have a local development server running Ubuntu, with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.