This event allows your Windows Forms application to handle otherwise unhandled exceptions that occur in Windows Forms threads. Attach your event handlers to the Application.ThreadException event to deal with these exceptions, which will leave your application in an unknown state. Where possible, exceptions should be handled by a structured exception handling block.
You can change whether this callback is used for unhandled Windows Forms thread exceptions by setting erload:System.Windows.Forms.Application.SetUnhandledExceptionMode. To catch exceptions that occur in threads not created and owned by Windows Forms, use the AppDomain.UnhandledException event handler.
To guarantee that no activations of this event are missed, you must attach a handler before you call erload:System.Windows.Application.Run.
Because this is a static event, you must detach your event handlers when your application is disposed, or memory leaks will result.