I need to make an foreach loop with 3 tasks, this needs to wait till all 3 tasks are finish and than move to next one. Something like
foreach (class r in sets) { Task.Factory.StartNew(() => { DoThisFunction1(); }, TaskCreationOptions.LongRunning); Task.Factory.StartNew(() => { DoThisFunction2(); }, TaskCreationOptions.LongRunning); Task.Factory.StartNew(() => { DoThisFunction3(); }, TaskCreationOptions.LongRunning); } somebody can give a simple way how to do this?