Open dotMorten opened 2 years ago
Soo... this is interesting. It appears that Neither of the above behaviors is correct. I ported your sample to plain Xamarin.Android and I get yet another result - the exception isn't thrown at all.
We appear to have 4 different behaviors:
It appears that 3.
is the correct behavior.
@grendello I've attached a WinUI app without MAUI and one that is MAUI. Both scenarios behave the same.
WinUI ExceptionTest.zip
MAUI MauiApp38.zip
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
VS2022, Version 17.3.0 Preview 2.0
Description
If I have a Task method that throws before the async work is done, without awaiting that method will cause the method to immediately throw on Windows and iOS. However on Android this call doesn't throw. and instead throws an unobserved task exception later.
Steps to Reproduce
Replace the MainPage.xaml.cs code with the following:
Run the application on Windows and iOS, and note button text changes to
Exception thrown as expected
. Next run this on Android, and note that first the button text changes toNo exception thrown !
, shortly after followed byUnobservedTaskException Thrown
.Did you find any workaround?
Await your tasks
Relevant log output
No response