standards-c-sharp

Prefer to start tasks with Task.Run

Prefer Task.Run over Task.Factory.StartNew over new Task().

When to use Task.Factory.StartNew

Don’t

Task.Factory.StartNew(MyMethod, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);

Do

Task.Run(() => MyMethod()); // equivalent to the above

When to use new Task()

Don’t

var task = new Task(MyMethod, CancellationToken.None, TaskCreationOptions.DenyChildAttach);
task.Start(TaskScheduler.Default);

Do

Task.Run(() => MyMethod()); // equivalent to the above