punker76 / MahApps.Metro.SimpleChildWindow

A simple child window for MahApps.Metro
MIT License
374 stars 55 forks source link

DialogManager throws InvalidOperationException when DialogMessage is shown in second time (Threads and SimpleChildWindow involved) #27

Closed jonny123d closed 8 years ago

jonny123d commented 8 years ago

Hello, I have been being a problem with message dialogs when I'm using threads and child windows. Here is exception's information:

System.InvalidOperationException

Message:
   Sequence contains more than one element

StackTrace:
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
   at MahApps.Metro.Controls.Dialogs.DialogManager.AddDialog(MetroWindow window, BaseMetroDialog dialog) in C:\Users\punker76\Documents\GitHub\MahApps.Metro\MahApps.Metro\Controls\Dialogs\DialogManager.cs:line 423
   at MahApps.Metro.Controls.Dialogs.DialogManager.SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) in C:\Users\punker76\Documents\GitHub\MahApps.Metro\MahApps.Metro\Controls\Dialogs\DialogManager.cs:line 413
   at MahApps.Metro.Controls.Dialogs.DialogManager.<>c__DisplayClass2_0.<ShowMessageAsync>b__1() in C:\Users\punker76\Documents\GitHub\MahApps.Metro\MahApps.Metro\Controls\Dialogs\DialogManager.cs:line 172
   at System.Windows.Threading.DispatcherOperation`1.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()

This is my environment:

I'm using Mahapps stable libraies:

I developed an application to show that: http://1drv.ms/1PZTAu1

There are 4 buttons or steps. You can reproduce the issue in 4 ways, following one of these steps sequences (only clicking step buttons and closing message dialogs):

This issue is opened on Mahapps.Metro too: https://github.com/MahApps/MahApps.Metro/issues/2321

punker76 commented 8 years ago

should be fixed with MahApps.Metro.SimpleChildWindow v1.3.0 and MahApps.Metro v1.2.3