c# - Call methods parallel and combine results -
i have mainmethod needs call 2 methods method1 , method2 parallel. both of them return list of employee different database. need call them parallel , combine results of method1 , method2 in mainmethod , return result caller of mainmethod.
i appreciate if people can tell must signatures of methods , code need write mean async/await keywords.
you can run them 2 task<t>
s. result property takes care of waiting. approximately:
// untested task<list<employee>> t1 = task.factory.startnew(() => method1()); task<list<employee>> t2 = task.factory.startnew(() => method2()); var result = t1.result.concat(t2.result);
Comments
Post a Comment