I was Trying to do some multithreading by calling Parallel.Invoke () => myMethod(Obj1),() => myMethod(Obj2));
so that those two methods would run parallel. Obj1
and Obj2
are objects from an external library. I did some debugging and found out that whenever myMethod
reaches to the point that it calls the external object’s method, i.e Obj.externalMethod()
, one of the myMethod
got paused indefinitely while the other myMethod
continues to run, any ideas why?
“No guarantees are made about the order in which the operations execute or whether they execute in parallel.”
That’s what the documentation about Parallel.Invoke
says.
Now I haven’t actually used Parallel.Invoke, and have no idea exactly why it blocks.
I always go for Tasks.
Have you tried using Task directly?
I gave it a try and your suggestion works! thank you.