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

Race condition in ShowMetroDialogAsync/HideMetroDialogAsync #2753

magla42 opened this Issue Nov 25, 2016 · 4 comments


None yet
2 participants

magla42 commented Nov 25, 2016

What steps will reproduce this issue?

We have a MetroDialog that when closed triggers an asynchronous operation that causes another MetroDialog to briefly get shown and then removed again.
Flashing dialogs like that is of course not a desireable behavior on our applications part and we are on it, but it uncovered a race condition in MahApps that I think ought to be fixed.

Depending on timing in ShowMetroDialogAsync and HideMetroDialogAsync, sometimes the original dialog is never removed from screen and that call to HideMetroDialogAsync never completes.

We have tracked down the problem to BaseMetroDialog._WaitForCloseAsync(), where the closingStoryboard.Completed event is never triggered, so the task never completes.
I would guess the storyboard is interrupted or suchlike due to the moving around of the dialog in the visual tree (metroActiveDialogContainer <--> metroInactiveDialogContainer)?

A workaround is to set DialogSettings.AnimateHide=false on the dialog (a related issue seems to be #2735).



  • MahApps.Metro v1.3.0
  • Windows 10
  • Visual Studio 2015
  • .NET Framework 4.6

This comment has been minimized.


punker76 commented Nov 25, 2016

@magla42 Can you create a short repo which shows exactly this issue? Thx.


This comment has been minimized.

magla42 commented Nov 25, 2016

I think I can do that. Probably won't be today though...


This comment has been minimized.

magla42 commented Dec 1, 2016

Here is a very small project that on my computer easily repeats the problem.

You open a CustomDialog with the button in the title bar, and when you close the dialog another CustomDialog is shown a (ridicilously) short time while the first dialog is closing. Almost every time this causes the HideMetroDialogAsync of the first dialog to never complete and the dialog to remain visible.


This comment has been minimized.


punker76 commented Jan 18, 2018

@magla42 I can't reproduce this with the latest source (upcoming v1.6), so I will close this for now. Feel free to reopen this if it's still an issue for you.

@punker76 punker76 closed this Jan 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment