-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement IAsyncDisposable on MauiApp #13424
Conversation
We do. We resorted to some ugly things to dispose it. |
Well it's just you and me then. The only humans on this planet to dispose a MauiApp! 😁 But in all seriousness, I'm curious your thoughts on this issue and the fix that was just merged. Does it help or hinder? Do you have remaining issues? Is it more about the challenge of how to even get MauiApp to be disposed as part of app shutdown? |
@Eilon Sorry for responding so late but I have tried this feature with .NET8p4 and it seems to work great! So we can remove workarounds we added. |
if (_services is IAsyncDisposable asyncDisposable) | ||
{ | ||
// Fire and forget because this is called from a sync context | ||
await asyncDisposable.DisposeAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PureWeen should this be using the FireAndForget method to avoid breaking the app? Maybe we can't log but we should at least catch the exceptions?
Fixes #13422
See the linked issue #13422 for more details. This change is required for some BlazorWebView test updates I want to make, because they register IAsyncDisposable services, and without this change if you call
MauiApp.Dispose()
(sync) you get an exception.Note that this change has no effect on any typical MAUI app because no one disposes the MauiApp object at all (the process just ends). But in tests we create/destroy many apps, and that's where I hit this.