UnobservedTaskException
ファイナライザーがオブジェクトで実行されているときに、監視されていない例外がアプリケーションを終了するのを防ぐために、を処理できることを知っています。
ただし、このイベントのハンドラーをいつ、どこに設定すればよいかわかりません。TaskScheduler
クラス内のイベント自体に関する XML ドキュメントには、次のように記載されています。
/// This AppDomain-wide event provides a mechanism to prevent exception
/// escalation policy (which, by default, terminates the process) from triggering.
/// Each handler is passed a <see cref="T:System.Threading.Tasks.UnobservedTaskExceptionEventArgs"/>
/// instance, which may be used to examine the exception and to mark it as observed.
これは、AppDomain 全体で 1 つのハンドラーしか必要ないということですか? そして、監視されていないすべてのタスク例外がそれによって処理されるということですか?
または、アセンブリごと/クラスごとにハンドラーが必要で、そのアセンブリ/クラス内のタスクからの監視されていない例外のみがそのハンドラーに送られますか?