Why was Task.Run() created in .NET, when Task.Factory.StartNew() is already available?

Posted: (EET/GMT+2)

 

When asynchronous tasks were introduces in .NET 4.0, creating a new task was most often done with the Task.Factory.StartNew() construct. With .NET 4.5, we got another, a shorter way: calling Task.Run().

So the question is: why was this new method necessary? The short answer is simplicity. The longer answer, as detailed in a Microsoft blog post, is that while Task.Factory.StartNew works just fine, Task.Run is easier to use, because all you need is a callback or an action method to work with. You don't need to specify cancellation tokens or run options.

In fact, Task.Run is just a wrapper around Task.Factory.StartNew.