1

I have come across two methods of invoking two methods in parallel way that are

Parallel.Invoke(new Action[]())

and

Task.WaitAll(new Task[]())

Can any body help to know what is the difference between them?

Jigna
  • 75
  • 1
  • 11
  • hi i think this has been covered: http://stackoverflow.com/questions/16101811/task-waitall-method-vs-parallel-invoke-method – capsch Sep 09 '13 at 12:00
  • Possible duplicate of [Task.Factory.StartNew vs. Parallel.Invoke](http://stackoverflow.com/questions/14130929/task-factory-startnew-vs-parallel-invoke) – nawfal Apr 20 '16 at 06:28

1 Answers1

0

Both the methods internally works on thread pool. There are different opinions which one to use amongst these two, I personally prefer Parallel.Invoke() for running actions parallel and wait for them after finishing.

hajirazin
  • 817
  • 8
  • 19
  • 2
    I am not sure, if this is correct. Task.WaitAll only waits for the tasks. Lets say they are some asynchronous I/O tasks. In this case they can also run without a thread pool and Parallel.Invoke creates "normal" thread-pool-tasks and waits for them to be finished. – SebastianStehle Sep 09 '13 at 13:52
  • @SebastianStehle I agree with you! I was just trying to summarize things for most general cases. any ways thanks for taking that point out. – hajirazin Sep 10 '13 at 04:15