トップ回答者
スレッドの例外処理について

質問
-
いつも拝見させていただいております。
以下のようにコードにおいて、
今回はスレッドの例外処理についてです。
public static void Main(string[] args)
button2_Clickにおいて、コメントアウトしているnewThreadについては、集約例外処理で拾えるのですが、SampleDelegateの方は拾う事ができません。
{
// Add the event handler for handling UI thread exceptions to the event.
Application.ThreadException += new ThreadExceptionEventHandler(Form1.Form1_UIThreadException); // Set the unhandled exception mode to force all Windows Forms errors to go through
// our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);// Add the event handler for handling non-UI thread exceptions to the event.
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);// Runs the application.
Application.Run(new Form1());
}private void button2_Click(object sender, System.EventArgs e)
{
//ThreadStart newThreadStart = new ThreadStart(newThread_Execute);
//Thread newThread = new Thread(newThreadStart);
//newThread.Start();// 非同期スレッドの実行
SampleDelegate a = new SampleDelegate(ThreadMethod);
a.BeginInvoke(null, null);
}// The thread we start up to demonstrate non-UI exception handling.
void newThread_Execute()
{
throw new Exception("The method or operation is not implemented.");
}private void ThreadMethod()
{
throw new Exception("非同期スレッドで起こった例外です。");
}private delegate void SampleDelegate();
これはAppDomainが違うからであると思っているのですが、それであっていますでしょうか?
また、現在拾えないが集約例外処理で拾えるようにすることは可能でしょうか?
よろしくお願いいたします。