title: XmlWriter async methods
body: <p>I have found example of async using of XmlWriter within msdn documentation <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx</a></p>
  
  <pre><code>async Task TestWriter(Stream stream) 
  {
      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Async = true;
      using (XmlWriter writer = XmlWriter.Create(stream, settings)) {
          await writer.WriteStartElementAsync("pf", "root", "http://ns");
          await writer.WriteStartElementAsync(null, "sub", null);
          await writer.WriteAttributeStringAsync(null, "att", null, "val");
          await writer.WriteStringAsync("text");
          await writer.WriteEndElementAsync();
          await writer.WriteProcessingInstructionAsync("pName", "pValue");
          await writer.WriteCommentAsync("cValue");
          await writer.WriteCDataAsync("cdata value");
          await writer.WriteEndElementAsync();
          await writer.FlushAsync();
      }
  }
  </code></pre>
  
  <p>All that I know about threads and async programming said me that this is too slow code and using synchronous Write methods will be much faster. I have modified this code and tested it. I have found that I'm right and synchronous code faster in 3-4 times on files more than 100Mb and more than 8-10 times faster on files less than 10mb on my env.</p>
  
  <p>So my question is there any scenario where such code is usable and provides reasonable performance gains?</p>