c# - How to make each method wait to complete another inside of parallel.Foreach? -
i have big problem "parallel for" using task parallel. want make methods , functions synchronous (wait on each other).
parallel.for(items, item=> { var = myclass1.function(foo.x); var b = myclass2.function(zoo.y, b.z); ---> should wait "a" result... var c = myclass2.method1(a.x,b.z); -----> should wait b result... });
how can that?
parallel.for
run in parallel across collection of items
. each item
processes, invoke given delegate synchronously. meaning, execute myclass1.function
myclass2.function
myclass2.method1
. assuming methods synchronous, , you're not doing in background threads inside of them.
imagine this:
items | | | | item1: item2: item3: item4: function1 function1 function1 function1 function2 function2 function2 function2 method1 method1 method1 method1
Comments
Post a Comment