.net asynchronus programming guide

Viewed 113

i`v been studing about async progrmaming in .net today and what i understood is that this code Should NOT create a new thread but i see different ThreadId with calling Thread.CurrentThread.ManagedThreadId.

  static void Main(string[] args)
    {
        Do();
        Console.WriteLine("Main {0}",Thread.CurrentThread.ManagedThreadId);

        Thread.Sleep(400);
    }

    private static async void Do()
    {
        Task<string> task = new StreamReader(@"D:\a.txt").ReadLineAsync();
        string result = await task;
        Console.WriteLine("DO {0}", Thread.CurrentThread.ManagedThreadId);
    }

thanks everyone for reading this..

1 Answers
Related