What is the idiomatic and fastest way to do the following in C#? Say I have a class that has three values (it is always three values so pre allocating 3 tasks is ok):
public class AggregateValues
{
public double A { get; set;}
public double B { get; set;}
public double C { get; set;}
}
public AggregateValues Compute()
{
//How do I parallize these?
AggregateValues av = new AggregateValues();
av.A = ComputeA();
av.B = ComputeB();
av.C = ComputeC();
//Wait for ComputeA, ComputeB, ComputeC to be done
return av;
}
public double ComputeA()
{
// Complicated code
}
public double ComputeB()
{
// Complicated code
}
public double ComputeC()
{
// Complicated code
}