-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add platform-specific main thread schedulers for MAUI #4212
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
Conversation
Introduces AndroidMainThreadScheduler and AppleMainThreadScheduler properties for platform-specific main thread scheduling. Updates WithMauiScheduler to use the appropriate scheduler based on the target platform, improving UI thread handling for Android, iOS, macOS, and Mac Catalyst.
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.
Pull request overview
This PR introduces platform-specific main thread schedulers for MAUI to resolve threading issues (#4185). The changes add AndroidMainThreadScheduler and AppleMainThreadScheduler properties that use platform-appropriate schedulers (HandlerScheduler for Android and NSRunloopScheduler wrapped in WaitForDispatcherScheduler for Apple platforms). The WithMauiScheduler method is updated to conditionally select the appropriate scheduler based on the target platform.
Key Changes
- Added
AndroidMainThreadSchedulerproperty usingHandlerScheduler.MainThreadSchedulerfor Android platforms - Added
AppleMainThreadSchedulerproperty usingWaitForDispatcherSchedulerwithNSRunloopSchedulerfor Apple platforms (iOS, macOS, Mac Catalyst) - Updated
WithMauiScheduler()to use platform-specific schedulers via conditional compilation
Introduces WinUIMauiMainThreadScheduler for WinUI/.NET MAUI main UI thread scheduling, guarded by WINUI_TARGET. Updates platform preprocessor directives to include TVOS and ensures correct scheduler is used per platform in WithMauiScheduler.
Corrected XML documentation comments to consistently use 'MAUI' in uppercase, improving clarity and adherence to naming conventions.
Updated MauiReactiveUIBuilderExtensions to use RxApp.UnitTestMainThreadScheduler when running in a unit test environment. Also changed UnitTestMainThreadScheduler's visibility from private to internal to allow access from the Maui project.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4212 +/- ##
==========================================
+ Coverage 33.90% 33.94% +0.03%
==========================================
Files 145 145
Lines 6264 6269 +5
Branches 943 944 +1
==========================================
+ Hits 2124 2128 +4
Misses 3973 3973
- Partials 167 168 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What kind of change does this PR introduce?
Fixes #4185
What is the current behavior?
#4185
What is the new behavior?
Introduces AndroidMainThreadScheduler and AppleMainThreadScheduler properties for platform-specific main thread scheduling. Updates WithMauiScheduler to use the appropriate scheduler based on the target platform, improving UI thread handling for Android, iOS, macOS, and Mac Catalyst.
What might this PR break?
Resolves a threading issue with Maui
Please check if the PR fulfills these requirements
Other information: