この例外を引き起こす条件を再現しようとしています:
System.AggregateException: A Task's exception(s) were not observed
either by Waiting on the Task or accessing its Exception property.
As a result, the unobserved exception was rethrown by the finalizer thread.`
私は例外を引き起こすだろうと考えてこのプログラムを書きましたが、そうではありません:
using System;
using System.Threading.Tasks;
namespace SomeAsyncStuff
{
class Program
{
static void Main(string[] args)
{
Task.Factory.StartNew(() => { throw new NullReferenceException("ex"); });
GC.Collect();
Console.WriteLine("completed");
}
}
}
私の実際のアプリケーションでは TPL を使用していますが、例外処理のコードを書いていません。その結果、その例外が発生します。現在、別のプログラムで同じ条件を再作成して、観察されていない例外を実験しようとしています。