using System.Diagnostics;
using System.Threading.Tasks;
throw new Exception("This exception is expected!");
throw new Exception("This exception is expected!");
public static void Main()
var task1 = new Task(foo2, CancellationToken.None, TaskCreationOptions.LongRunning);
catch (AggregateException ae)
foreach (var e in ae.InnerExceptions) {
Console.WriteLine("E: " + e.Message);