using System.Threading.Tasks;
using System.Collections.Generic;
public static async void Main()
Console.WriteLine("Hello World");
TestTaskWhenAllException("only 1 that throws", Throws());
TestTaskWhenAllException("only 1 that no throws", NoThrows());
TestTaskWhenAllException("2 tasks, 1 that throws", Throws(), NoThrows());
TestTaskWhenAllException("2 tasks, the other that throws", NoThrows(), Throws());
TestTaskWhenAllException("2 tasks that throw", Throws(), Throws());
TestTaskWhenAllException("2 tasks that no throw", NoThrows(), NoThrows());
private static async void TestTaskWhenAllException(string name, params Task[] tasks) {
Console.WriteLine("Testing " + name);
Task task = Task.WhenAll(tasks);
Console.WriteLine("\t"+e.GetType().ToString());
Console.WriteLine("\t"+task.Exception.GetType().ToString() + " with " + task.Exception.InnerExceptions.Count + " inner");
Console.WriteLine("\t"+(e == task.Exception).ToString());
private static async Task Throws() {
throw new Exception("Hello");
private static async Task NoThrows() {