Repository navigation
test: a view model's InitializationComplete is its newest load, so a test waits for the one still running - #2948
Merged
laurentiu021 merged 1 commit intoOct 22, 2026
Conversation
…test waits for the one still running - InitializeAsync set InitializationComplete to the task RunInitAsync returned, once RunInitAsync had already run the load to its first await. A load that resumed on another thread in that window, as one does when no dispatcher queues it, which is how the unit tests run, could start a second load first, and the older task then replaced the newer one. A Display Profiles test failed that way on CI: its wait ended before the selected display's modes were read (#2947). - The property is now set before the load starts, from an unstarted task run in place, so a load started later sets it later. - Behaviour in the app is unchanged. The tabs that read the property start one load each, and the two that start a load from another, Display Profiles and Bulk Installer, start it after an await or on a change the user makes.
| // does when no dispatcher queues it, can start a second load before then, and setting the property afterwards | ||
| // replaced that newer load's task with this older one, so whoever awaited it went on while the newer load was | ||
| // still running (#2947). | ||
| var start = new Task<Task>(() => RunInitAsync(asyncAction, callerName)); |
laurentiu021
deleted the
test/initialization-complete-is-the-newest-load
branch
October 22, 2026 00:40
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.
ViewModelBase.InitializeAsyncsetInitializationCompleteto the taskRunInitAsyncreturned, and by thenRunInitAsynchad already run the load to its firstawait. A load that resumed on another thread in that window, asone does when no dispatcher queues it, which is how the unit tests run, could start a second load through
InitializeAsyncfirst, and the older task then replaced the newer one. A test awaiting the property went on whilethe newer load was still running.
DisplayProfileViewModelTests.AWindowsDisplayChange_ReadsTheDisplaysAgain_AndLeavesTheStatusLineAlonefailed that wayon #2945's first CI run: reading the displays selects one, which starts reading its modes, and the test's wait ended
before they were read, so Keep said "Display set to ." with no mode in it.
What changed
InitializeAsyncbuilds the load as an unstarted task, sets theproperty to it, and runs it in place on the calling thread, as the direct call did. A load started later sets the
property later.
their first load is done) start one load each. The two tabs that start a load from another, Display Profiles and
Bulk Installer, start it after an
awaitor on a change the user makes.Tests
ViewModelBaseTests.InitializationComplete_IsTheNewestLoad_WhenItStartedBeforeTheFirstReturned: a load that startsa second one on another thread before its own call returns. Before the change the property was the first load's
task, already finished; it is now the second's, still running until the test completes it.
fault tests, which await the property for what a load threw.
Closes #2947.