-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
What steps will reproduce this issue?
Attempting to call HideMetroDialogAsync and ShowMetroDialogAsync on two dialogs in rapid succession, with animations on, will sometimes cause HideMetroDialogAsync to never return and thus leave a dialog on the screen perpetually. This is a timing-based bug and can be somewhat difficult to reproduce.
I have done some debugging and have tracked the problem to an issue with WPF's Storyboard class; apparently it does not always fire its Completed event when multiple storyboards are created. Since BaseMetroDialog._WaitForCloseAsync listens to this event, it sometimes fails to complete too.
Note that, while this issue is similar to #2753, the workaround suggested there is not sufficient to solve this problem; both AnimateShow and AnimateHide must be set to to false to avoid it. A possible workaround would be to timeout the _WaitForCloseAsync task if the Completed event takes too long to fire.
Expected outcome
Dialogs attempting to open/close at the same time should do so successfully.
Repo
This repo (originally submitted as a .zip file in issue #2753 and submitted here with the original author's permission) can somewhat reliably reproduce the bug. The application opens a dialog at the press of a button; when that dialog is closed, a second dialog is very briefly opened and closed too. This will sometimes cause the original dialog to remain open. Repeatedly opening and closing the dialog should eventually trigger the bug.
https://github.com/AndreasZChen/MahAppsRace
Environment
- MahApps.Metro v1.5.0
- Windows OS 10
- Visual Studio 2017
- .NET Framework 4.7