0

Which is the best way to start a task in C# (if there are any differences?) The ways I've found but not sure which one to use:

//Using run
Task.Run(()=> MyMethod());

//Using factory
Task.Factory.StartNew(() => MyMethod(); });

//Using action
Task task = new Task(new Action(MyMethod));
task.Start();

//Using lambda
Task task = new Task(() => MyMethod() );
task.Start();


private void MyMethod()
{
   //Do stuff
}
Marcus Höglund
  • 16,172
  • 11
  • 47
  • 69

0 Answers0