I was looking at this MSDN documentation on Task.Run https://msdn.microsoft.com/en-us/library/hh195051(v=vs.110).aspx
One of the complete example look like the following
using System;
using System.Threading;
using System.Threading.Tasks;
public class Example
{
public static void Main()
{
ShowThreadInfo("Application");
var t = Task.Run(() => ShowThreadInfo("Task") );
t.Wait();
}
static void ShowThreadInfo(String s)
{
Console.WriteLine("{0} Thread ID: {1}",
s, Thread.CurrentThread.ManagedThreadId);
}
}
It does not seem to leverage the benefit of asynchronous programming when starting the task and then wait immediately. All MSDN documentation examples on Task.Run
, Task.Start
, Task.StartNew
etc. look like this. Is this just bad documentation or am I missing something?