I want to prevent my app from closing after an unhandled exception has been raised.
I'm doing this with Xamarin and MonoMac, but I think I could translate Objective-C answers to C#.
When an Exception happens and it's not caught anywhere, I register the event of unhandled exceptions:
AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
And log it:
static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//Log the exception...
}
But then, when an exception happens, the HandleUnhandledException is executed and the event loop is exited:
NSApplication.Main(args);
So my app ends. How can I avoid this? Where should I place a try-catch block?