title: FileStream WriteAsync and await confusion
body: <p>I'm looking at the new <code>async</code> and <code>await</code> keywords in C# and just trying to get a feel for them.</p>
  
  <p>I'm looking at the MSDN <code>FileStream.WriteAsync()</code> <a href="http://msdn.microsoft.com/en-us/library/hh158629.aspx" rel="noreferrer">example</a>, and I wasn't sure I understood something.</p>
  
  <p>The example is as follows:</p>
  
  <pre><code>using System;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.IO;
  
  namespace WpfApplication1
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
          }
  
          private async void Button_Click(object sender, RoutedEventArgs e)
          {
              UnicodeEncoding uniencoding = new UnicodeEncoding();
              string filename = @"c:\Users\exampleuser\Documents\userinputlog.txt";
  
              byte[] result = uniencoding.GetBytes(UserInput.Text);
  
              using (FileStream SourceStream = File.Open(filename, FileMode.OpenOrCreate))
              {
                  SourceStream.Seek(0, SeekOrigin.End);
                  await SourceStream.WriteAsync(result, 0, result.Length);
              }
          }
      }
  }
  </code></pre>
  
  <p>What I don't get is the placement of the <code>await</code>. It seems that you can't take the <code>Task</code> item that is returned by <code>WriteAsync()</code> because this always gives me a syntax error. So the only way I could get this to compile is by leaving the <code>await</code> with the call.</p>
  
  <p>But if you do this, does it not wait for the call to finish? This makes it not very asynchronous...</p>