I am testing exception handling in my Xamarin.Forms App. I have to buttons that are bound to two commands.
One raises an Exception on the UI thread, the other one is rasied in a background thread.
throw new Exception("Testing application wide ui exception handling.");
vs
Task.Run(() => { throw new Exception("Testing application wide background exception handling."); });
In my MainActivity, I am subscribing the uncaught excption handlers
AndroidEnvironment.UnhandledExceptionRaiser += OnUnhandledUIThreadException;
AppDomain.CurrentDomain.UnhandledException += OnUnhandledBackgroundThreadException;
Now, when i click to raise the exception on the UI thread, OnUnhandledUIThreadException is called.
But, when i click to raise the background exception, the exception is never raised somewhere. The OnUnhandledBackgroundThreadException is not called, and the application is still running.
Anybody knows whats going on?