Execute parallel tasks with async/await

.net, async-await, c#, silverlight

Solution

For Silverlight I assume you're using the Microsoft.Bcl.Async package.

Since this (add-on) package cannot modify the (built-in) `Task` type, you'll find some useful methods in the `TaskEx` type. Including `WhenAll`:

await TaskEx.WhenAll(...);

Problem

I need to execute multiple async tasks in Silverlight. Documentation of the 3rd party package states I can use ``` await Task.WhenAll() ``` Unfortunately silverlight only have `Task.WaitAll()` and it is not awaitable. If I try to use it I get deadlock (I assume - because whole thing freezes) What is the proper pattern to use in async method?

Original source