using System.Threading.Tasks;
public static void Main()
Console.WriteLine("Current managed thread id in Main(): {0}",System.Threading.Thread.CurrentThread.ManagedThreadId);
Func<string, string, Task<string>> foo = async (str,name) =>
var wc = new System.Net.WebClient();
Console.WriteLine("Current managed thread id in func {1}: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId, name);
return await wc.DownloadStringTaskAsync(str);
foo("http://www.google.com","async version");
Console.WriteLine("** happens before taskfactorycall but after async invoked");
var bar2 = Task.Factory.StartNew(() => foo("http://www.google.com","task factory version"));
var b3 = bar2.ContinueWith((c) => Console.WriteLine("task completed: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId));
Console.WriteLine("** happens after task factory call invoked");