Yaron Levi Yaron Levi - 1 year ago 239
C# Question

WaitAll vs WhenAll

What is the difference between

from the Async CTP ?
Can you provide some sample code to illustrate the different use cases ?

Answer Source

Task.WaitAll blocks the current thread until everything has completed.

TaskEx.WhenAll returns a task which represents the action of waiting until everything has completed.

That means that from an async method, you can use:

await TaskEx.WhenAll(tasks);

... which means your method will continue when everything's completed, but you won't tie up a thread to just hang around until that time.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download