From 4edcdf09558dec23a74e89774a966e261902c339 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Mon, 9 Jan 2023 11:46:56 +0200 Subject: [PATCH] Ignore race conditions when closing dialogs --- .../ViewModels/Framework/DialogManager.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs b/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs index d6902d2..051c0f9 100644 --- a/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs +++ b/DiscordChatExporter.Gui/ViewModels/Framework/DialogManager.cs @@ -27,7 +27,15 @@ public class DialogManager : IDisposable { void OnScreenClosed(object? closeSender, EventArgs args) { - openArgs.Session.Close(); + try + { + openArgs.Session.Close(); + } + catch (InvalidOperationException) + { + // Race condition: dialog is already being closed + } + dialogScreen.Closed -= OnScreenClosed; } dialogScreen.Closed += OnScreenClosed;