title: Async/await - any changes in .NET 4.6 or .NET Core?
body: <p><strong>Hi All</strong>,</p>
  
  <p>I plan to develop a <strong>custom awaiter</strong> quite similar to one presented in this brilliant article: </p>
  
  <blockquote>
    <p><a href="http://blogs.msdn.com/b/lucian/archive/2012/11/24/how-to-hibernate-async-methods-how-to-serialize-task.aspx" rel="nofollow">http://blogs.msdn.com/b/lucian/archive/2012/11/24/how-to-hibernate-async-methods-how-to-serialize-task.aspx</a></p>
  </blockquote>
  
  <p>In short, it allows serializing the state of an async method, to be deserialized and resumed at a later time. </p>
  
  <p><strong>My concern</strong> is that the implementation (for .NET 4.5) is based on a hack of accessing a private field <code>m_stateMachine</code> of struct <code>AsyncMethodBuilderCore</code>, which is an internal type in <strong>mscorlib</strong>. </p>
  
  <p><strong>I edited the question</strong> following @Peter's comment:</p>
  
  <p>I wonder if anyone who installed .NET 4.6 or .NET Core (ASP.NET 5) previews and investigated async/await in those versions, saw any change in how the compiler generates the state machine behind async/await, compared to .NET 4.5?</p>
  
  <p><strong>Some background</strong></p>
  
  <p>I am exploring possibility of authoring long-running workflows (similar to those provided by Windows Workflow Foundation) using C# async/await syntax. Which means that in my case, async/await must be backed by persistence and tracking mechanisms. Then the code of a workflow would look like this:</p>
  
  <pre><code>public class ProcessingWorkflowOfForm12345C : AbstractWorkflow&lt;Form12345C&gt;
  {
      private readonly ExternalServices _services;
  
      public ProcessingWorkflowOfForm12345C(ExternalServices services)
      {
          _services = services;
      }
  
      public override async void Run(Form12345C form)
      {
          while ( form.ExtraDocumentsRequired )
          {
              var extraDocuments = await _services.RequestExtraDocuments(
                  form.GetRequiredExtraDocuments()); // can take weeks
              form.AddExtraDocuments(extraDocuments);
          }
  
          var approvalResult = _services.AutoApprove(form);
  
          while ( true )
          {
              switch ( approvalResult )
              {
                  case ApprovalResult.Approved:
                      form.SetApproved();
                      return;
                  case ApprovalResult.Rejected:
                      form.SetRejected();
                      return;
                  case ApprovalResult.Manual:
                      approvalResult = 
                          await _services.RequestManualApproval(form); // can take days
                      break; 
              }
          }
      }
  }
  </code></pre>