title: Calling an async method from a non-async method
body: <p>Every variation on the following code that I try doesn't work - whether <code>DoSomething() : void</code> and is called as written, or <code>DoSomething() : Task</code> and is called with <code>TaskEx.RunEx()</code>, some attempt involving <code>.GetAwaiter().GetResult()</code>.  Errors seen include: <code>"Start may not be called on a task with null action"</code>, <code>"RunSynchronously may not be called on a task unbound to a delegate"</code>, and <code>"The task has not yet completed"</code>.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args) // Starting from a non-async method
      {
          DoSomething();
  
          Console.WriteLine("Press any key to quit.");
          Console.ReadKey();
      }
  
      static async void DoSomething()
      {
          Console.WriteLine("Starting DoSomething ...");
  
          var x = await PrepareAwaitable(1);
  
          Console.WriteLine("::" + x);
  
          var y = await PrepareAwaitable(2);
  
          Console.WriteLine("::" + y);
      }
  
      static Task&lt;string&gt; PrepareAwaitable(int id)
      {
          return new Task&lt;string&gt;(() =&gt;
          {
              return "Howdy " + id.ToString();
          });
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>Starting DoSomething ...</p>
    
    <p>Press any key to quit.</p>
  </blockquote>
  
  <p><code>PrepareAwaitable</code>'s <code>Task</code>'s <code>Action</code> will be more complicated later. When this action completes, however long that takes, I would expect the <code>Task</code> (or other Framework mechanisms) to resume by assigning <code>"Howdy ..."</code> to x, and then later to y. What I REALLY want to do is intercept the awaited objects, process them, and at some later time that I control, resume to the continuation with a result (<code>x</code> and <code>y</code>). But I haven't been getting very far on that big step, so I'm trying to start smaller.</p>