Read file asynchronously - CSharp Thread Asynchronous

CSharp examples for Thread Asynchronous:Async

Description

Read file asynchronously

Demo Code

using System;/*  www  .j av  a  2  s .  c  om*/
using System.IO;
class Program
{
    static async void Main(string[] args)
    {
        using (StreamReader reader = new StreamReader("test-file.txt"))
        {
            string contents = await reader.ReadToEndAsync();
            Console.WriteLine("File contents:");
            Console.WriteLine(contents);
        }
    }
}

Related Tutorials