I have a method that contains a series of method calls in it. Some of these method calls can occur at once and some have to be done sequentially. What is the most straight forward way to implement that in Task Parallel Library. All functions are calculation heavy and take less than a second to run.
i.e.
public object MyMethod(InputClass myInput)
{
var result = method1(myInput);
var result1 = method2(result);
var result2 = method3(result);
var finalResult = method4(result1, result2);
return finalResult;
}
Method1 must be executed 1st, method2 + method3 can be executed in parallel, method4 must be executed last.
I believe this would give the the level of parallelism you require, with method 2 and 3 being executed concurrently.
EDIT: Updating with some types, assuming all your methods return
object.