using System.Threading.Tasks;
public static void Main(string[] args)
File.WriteAllText("test.txt", "read from file");
Read(File.OpenText("test.txt")).Wait();
Read(new StreamReader(File.Create("testTwo.txt"))).Wait();
Read(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes("read from another string")))).Wait();
Console.WriteLine("{0}: {1}", Thread.CurrentThread.ManagedThreadId, "main thread");
static async Task Read(StreamReader sr)
var s = await sr.ReadToEndAsync();
Console.WriteLine("{0}: {1}", Thread.CurrentThread.ManagedThreadId, string.IsNullOrEmpty(s) ? "nothing written to the file" : s);