-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
My UWP project lives inside a XamlIsland, that is, I have a WPF application having a WindowsXamlHost that in turn hosts a UWP control. Since #2100 any access to RxApp.MainThreadScheduler results in an Exception.
The root cause is that in the newly introduced SingleWindowDispatcherScheduler the dispatcher is fetched via CoreApplication.Views[0].Dispatcher, but this is not present inside the XamlIsland Context. CoreApplication.Views.Count is > 0, but subsequently accessing .Dispatcher results in an Exception.
Steps To Reproduce
see https://github.com/jasonwurzel/XamlIslandDispatcherProblem for a repo. Start either ControlPlaygroundPackage (WPF - XamlIsland - Uwp) or UwpApp (UWP App) (in Debug - x64). Starting UwpApp results in no exception, starting the WPF App results in an exception when CoreApplication.Views[0].Dispatcher is accessed.
- Min Windows version is 1903
- dotnet core sdk 3.0.100-preview5-011568 is expected to be present
Expected behavior
Accessing RxApp.MainThreadScheduler should not result in an exception. If it is correct that the Views in the Views enumeration have no dispatcher in the XamlIsland case, we have to find a workaround in that special case.
Additional context
I'm not sure whether the views in the Views enumeration should have a Dispatcher present or not. I'll check with the Windows.Toolkit guys as well.
For simplicity's sake I ommitted referencing the actual ReactiveUI package in my repro (XamlIslands with 3rd party nuget references is still uncharted territory, unfortunately and requires some - more - fiddling with the csproj files.)