maui icon indicating copy to clipboard operation
maui copied to clipboard

Remove calls to scoped services on root provider

Open PureWeen opened this issue 2 years ago • 1 comments

Description of Change

Alternative approach for https://github.com/dotnet/maui/pull/18492.

This approach opts for changing current behavior as little as possible for NET8. Instead of changing the behavior of IMauiInitializeScopedService this just stops using it. AFAICT it's not really providing any current value for us. We can just use IMauiInitializeService to achieve the same workaround for WinUI.

The main behavior change here is how to handle the first call to IDispatcher from the service provider scoped to the window.

Behavior Change

Currently in MAUI if you try to retrieve the Dispatcher from the scoped service provider on a background thread it just returns null, but this captures the dispatcher when the window scope is created. Which is probably a better experience.

https://github.com/dotnet/maui/pull/19593/files#diff-500f3422fdff10304272c2e7985ec98941543f788bef70ac1fb1b23776bb1104R49-R55

Added issue here to evaluate the correctness of IMauiInitializeScopedService because this interface currently only initializes once at the application level, it doesn't actually initialize for each scoped service we create.

Issues Fixed

Fixes #11457

PureWeen avatar Dec 26 '23 18:12 PureWeen

/rebase

PureWeen avatar Jan 05 '24 19:01 PureWeen