Possible fix for multi-thread usage of DialogHost.GetInstance()#2849
Merged
Keboo merged 5 commits intoMaterialDesignInXAML:masterfrom Sep 16, 2022
Merged
Possible fix for multi-thread usage of DialogHost.GetInstance()#2849Keboo merged 5 commits intoMaterialDesignInXAML:masterfrom
Keboo merged 5 commits intoMaterialDesignInXAML:masterfrom
Conversation
Contributor
Author
|
@Keboo I don't understand the latest failures of this PR verification. Is it the double-source generator issue coming into play again? |
Replace obsolete Thread.Abort() with proper shutdown of Dispatcher instead.
Keboo
approved these changes
Sep 16, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Possible fix for #2844
I added a unit test which initially failed with the same exception as reported in the issue. Slight modifications to the
DialogHost.GetInstance()were added in order to retrieve the identifier using theDispatcherassociated with the owning thread. This makes the test run green. This change effectively replaces theDispatcher.VerifyAccess()call by using the owning thread when needed.As mentioned in the bug, the
Dispatcher.VerifyAccess()guard was to some extent unnecessary because the followingdialogInstance.IdentifierDP-getter would result in the same exception being thrown.I am a bit unsure whether there could be other areas where a similar approach would be needed.