Exceptions
いくつかのタスクの実行中にスローされることについて報告したい:
//waiting for all the tasks to complete
try
{
Task.WaitAll(task1, task2, task3);
}
catch (AggregateException ex)
{
//enumerate the exceptions
foreach (Exception inner in ex.InnerException)
{
Console.WriteLine("Exception type {0} from {1}", inner.GetType(), inner.Source);
}
}
ただし、foreach
その場合はループを使用できません。
その問題の回避策はありますか?