Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Android: Exceptions in Background Tasks are silently caught

$
0
0

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?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>