Task.Factory.StartNew is dangerous should not use

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
var task1 = Task.Factory.StartNew(() => results.LeftFront.CalcAi());
var task2 = Task.Factory.StartNew(() => results.RightFront.CalcAi());
var task3 = Task.Factory.StartNew(() =>results.RearSuspension.CalcAi(geom,
vehDef.Geometry.LTa.TaStiffness,
vehDef.Geometry.RTa.TaStiffness));

Task.WaitAll(task1, task2, task3);

this link saying we should not use StartNew rather use Task.Run() StartNew is Dangerous

if above function are returning data then how could i store the return value in other variable ? again tell me how to know all the function running parallel completed?

some links

Simplest way to run three methods in parallel in C#
Call methods parallel and combine results

please guide. thanks

Continue reading...
 
Back
Top