using System.Threading.Tasks;
public static void Main()
Console.WriteLine("Hello World");
AutoResetEvent ev = new AutoResetEvent(false);
ThreadPool.QueueUserWorkItem(async delegate
catch (InvalidOperationException)
Console.WriteLine("IOE 1");
catch (AggregateException)
Console.WriteLine("AggregateException 1");
string result = ThrowException().Result;
catch (AggregateException)
Console.WriteLine("AggregateException 2");
public static async Task<string> ThrowException()
throw new InvalidOperationException("I am invalid!");