次のコードを実行しようとしています。
class Program
{
static void Main(string[] args)
{
var task = Task.Factory.StartNew(() =>
{
throw new ApplicationException("message");
});
try
{
task.ContinueWith(t => Console.WriteLine("End"));
}
catch (AggregateException aex)
{
Console.Write(aex.InnerException.Message);
}
}
}
Exception
が次の場所でキャッチされると予想しました。
catch (AggregateException aex)
{
Console.Write(aex.InnerException.Message);
}
しかし、これは起こっていません。これはなぜですか?