Uh oh!
There was an error while loading. Please reload this page.
Conversation
nicolaihenriksen
approved these changes
Aug 22, 2026
nicolaihenriksen
left a comment
Contributor
There was a problem hiding this comment.
Only some minor comments. Looks good to me though.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Member
There was a problem hiding this comment.
Looks great already, good idea.
- Are the WaitFor* methods named properly?
LGTM
- Tests, need to have them. Will be impossible to test race conditions reliably, but happy path should be there.
Agree
- Should the CancelationToken int he WaitFor* methods be required rather than optional?
Besides what @nicolaihenriksen already mentioned (using a default timeout if none is supplied), what about adding an overload that takes a TimeSpan?
publicTaskWaitForClosed(TimeSpantimeout){usingCancellationTokenSourcects=new(timeout);returnWaitForClosed(cts.Token);}Shouldn't the WaitFor* methods be static, or am I misunderstanding the design of the public API?
Edit:
I overlooked your example and now understand how you intended the API: register forDialogClosingEventHandlerand callawait eventArgs.Session.DialogHost.WaitForClosed();in the handler.
To improve discoverability (and maybe developer experience?), thoughts on adding static methods for WaitFor* like so?
publicstaticTaskWaitForOpened(object?dialogIdentifier=null,CancellationTokencancellationToken=default){varinstance=GetInstance(dialogIdentifier);returninstance.WaitForOpened(cancellationToken);}publicstaticTaskWaitForClosed(object?dialogIdentifier=null,CancellationTokencancellationToken=default){varinstance=GetInstance(dialogIdentifier);returninstance.WaitForClosed(cancellationToken);}// usage:awaitDialogHost.Show(...);awaitDialogHost.WaitForClosed();Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Introduces `WaitForOpened` and `WaitForClosed` methods on `DialogHost` to enable asynchronous waiting for the completion of the dialog's visual state transitions. This provides more precise control for executing logic precisely after the dialog has fully opened or closed, rather than just when events are dispatched. Updates the `DialogSession` to expose the parent `DialogHost` instance, facilitating access to these new awaitable methods.
The `VisualStateMonitor` failed to correctly identify the 'Open' and 'Closed' states due to an incorrect type cast (`OfType`) when retrieving state names. This prevented the `WaitForOpened` and `WaitForClosed` methods from functioning as intended. This change corrects the type to `VisualState` to ensure proper state detection. Adds a new UI test to confirm the `WaitForClosed` method completes reliably. Fixes#4017.
Ensures `WaitForOpened` and `WaitForClosed` handle cancellation tokens correctly by unsubscribing from `VisualStateGroup` events. This prevents potential resource leaks and ensures reliable cancellation. Adds tests to confirm that waiting methods complete immediately if the dialog is already in the target visual state, enhancing predictability. This also validates the overall reliability of asynchronous state transitions. Fixes#4017.
Keboo
marked this pull request as ready for review
August 28, 2026 05:31
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Potential Fix for #4017
Introduces
WaitForOpenedandWaitForClosedmethods onDialogHostto enable asynchronous waiting for the completion of the dialog's visual state transitions. This provides more precise control for executing logic precisely after the dialog has fully opened or closed, rather than just when events are dispatched.Outstanding items:
Updates the
DialogSessionto expose the parentDialogHostinstance, facilitating access to these new awaitable methods.