title: A method was called at an unexpected time
body: <p>I'm trying to iterate all files in a directory using GetFilesAsync, but every time I call the GetResults method, it throws an exception that says</p>
  
  <blockquote>
    <p>System.InvalidOperationException: A method was called at an unexpected
    time</p>
  </blockquote>
  
  <p>The code is simply</p>
  
  <pre><code>var files = myStorageFolder.GetFilesAsync(); //runs fine
  var results = files.GetResults(); //throws the exception
  </code></pre>
  
  <p>I'm new to Win 8 dev so I might be missing something obvious. </p>
  
  <p><strong>Edit (solved)</strong>
  I'm running my console application, but now that the program runs async, the <code>files.GetResult()</code> method no longer exists. </p>
  
  <pre><code>static void Main(string[] args)
  {
     var files = GetFiles(myStorageFolder);
     var results = files.GetAwaiter().GetResults();//Need to add GetAwaiter()
  }
  
  static async Task GetFiles(StorageFolder sf)
  {
     await sf.GetFilesAsync();
  }
  </code></pre>