-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Programmatically closing a dialog #2633
Comments
why would you not await the ShowModalAsync? Why not just use ShowModal? |
For comparison, Windows Forms allows to attach a form to a parent, show the form in a way that blocks only while the UI is being built and allowing the form to be disposed of immediately after. Largely due to there being no reliable callback/event it seems to be impossible to close a modal immediately after its creation, regardless of whether the call to ShowModalAsync is awaited or not. Eto Forms could also handle this attempt better by either aborting the UI construction or scheduling its destruction if Dispose/Close is called before the UI element is fully constructed. |
I used a Dialog as a progress/busy indicator for some long-running operations in an application. The Dialog is displayed using ShowModalAsync, locking the parent Form/Dialog, while allowing the application code to start the long running operation and eventually Close the dialog and wait for the ShowModalAsync task to complete and Dispose the form. This seems to work fine sometimes, but breaks down when the operation completes synchronously.
I have tried to wait for the OnShown event to be raised before calling the Close/Dispose methods, and while this seems to work for Wpf it does not seem like a reliable solution, causing different effects on Gtk and possibly not working at all on Mac (#2254).
Is the use of a Dialog as a programmatically controlled progress/busy indicator acceptable? Would there be a better approach to achieve the desired behavior?
Expected Behavior
The dialog opens, blocking the main UI, and closes immediately after, or does not show at all.
Actual Behavior
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: