-
Notifications
You must be signed in to change notification settings - Fork 1.9k
If the current thread dispatcher is null return the app level dispatcher #20313
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1ca872e
If the current thread dispatcher is null return the app level dispatcher
PureWeen a0f3ade
- switch to better method
PureWeen 9d2ee8b
- If we're using FindDispatcher on the Application return Application…
PureWeen a59cedd
- app dispatcher
PureWeen e69f1aa
Update AppHostBuilderExtensions.cs
PureWeen 19c5b93
Update src/Controls/src/Core/DispatcherExtensions.cs
PureWeen 8a7abf1
- add tests
PureWeen 1fb613d
- add iOS to IVT list
PureWeen 4a3bcab
- add winui tests to IVT
PureWeen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Controls/samples/Controls.Sample.UITests/Issues/IsInvokeRequiredRaceCondition.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Maui; | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Graphics; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.None, 1, "Application.Current.Dispatcher.IsDispatchRequired race condition causes crash")] | ||
| public class IsInvokeRequiredRaceCondition : TestContentPage | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var button = new Button | ||
| { | ||
| AutomationId = "crashButton", | ||
| Text = "Start Test" | ||
| }; | ||
|
|
||
| var success = new Label { Text = "Success", IsVisible = false, AutomationId = "successLabel" }; | ||
|
|
||
| var instructions = new Label { Text = "Click the Start Test button. " }; | ||
|
|
||
| Content = new StackLayout | ||
| { | ||
| HorizontalOptions = LayoutOptions.Fill, | ||
| VerticalOptions = LayoutOptions.Fill, | ||
| Children = { instructions, success, button } | ||
| }; | ||
|
|
||
| button.Clicked += async (sender, args) => | ||
| { | ||
| await Task.WhenAll(GenerateTasks()); | ||
| success.IsVisible = true; | ||
| }; | ||
| } | ||
|
|
||
| List<Task> GenerateTasks() | ||
| { | ||
| var result = new List<Task>(); | ||
|
|
||
| for (int n = 0; n < 1000; n++) | ||
| { | ||
| result.Add(Task.Run(() => { var t = Application.Current.Dispatcher.IsDispatchRequired; })); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Controls/tests/UITests/Tests/Issues/IsInvokeRequiredRaceCondition.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.AppiumTests.Issues; | ||
|
|
||
| public class IsInvokeRequiredRaceCondition : _IssuesUITest | ||
| { | ||
| public IsInvokeRequiredRaceCondition(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Application.Current.Dispatcher.IsDispatchRequired race condition causes crash"; | ||
|
|
||
| [Test] | ||
| public void ApplicationDispatcherIsInvokeRequiredRaceConditionCausesCrash() | ||
| { | ||
| App.WaitForElement("crashButton"); | ||
| App.Click("crashButton"); | ||
| App.WaitForElement("successLabel"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.