title: Reading all lines from file asynchronously and safely
body: <p>I'm trying to read from a file asynchronously, and safely (minimum level of permissions sought). I'm using .NET 3.5 and cannot find a good example for this (all uses async and await).</p>
  
  <pre><code> public string GetLines()
      {
          var encoding = new UnicodeEncoding();
          byte[] allText;
          using (FileStream stream =File.Open(_path, FileMode.Open))
          {
              allText = new byte[stream.Length];
              //something like this, but does not compile in .net 3.5
              stream.ReadAsync(allText, 0, (int) allText.Length);
          }
          return encoding.GetString(allText);
      }  
  </code></pre>
  
  <p>Question is, how do I do this asynchronously in .net 3.5, wait till the operation is finished and send back all lines to the caller?</p>
  
  <p>The caller can wait till the operation is complete, but the read has to happen in a background thread.</p>
  
  <p>The caller is a UI thread, and I'm using .NET 3.5</p>