Unify CloseAsync
MODIFY
WalletWasabi.Gui/CommandLine/CrashReportCommand.cs
WalletWasabi.Gui/CommandLine/CrashReportCommand.cs
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using WalletWasabi.Helpers;
using Newtonsoft.Json;
using WalletWasabi.Logging;
-using WalletWasabi.Gui.Models.CrashReport;
+using WalletWasabi.Gui.CrashReport;
namespace WalletWasabi.Gui.CommandLine
{

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -27,9 +27,9 @@ using WalletWasabi.Blockchain.TransactionProcessing;
using WalletWasabi.CoinJoin.Client;
using WalletWasabi.CoinJoin.Client.Clients;
using WalletWasabi.CoinJoin.Client.Clients.Queuing;
+using WalletWasabi.Gui.CrashReport;
using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.Models;
-using WalletWasabi.Gui.Models.CrashReport;
using WalletWasabi.Gui.Rpc;
using WalletWasabi.Helpers;
using WalletWasabi.Hwi.Models;

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -56,15 +56,7 @@ namespace WalletWasabi.Gui
}
finally
{
- MainWindowViewModel.Instance?.Dispose();
- Global.DisposeAsync().GetAwaiter().GetResult();
- AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
- TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
-
- if (runGui)
- {
- Logger.LogSoftwareStopped("Wasabi GUI");
- }
+ CloseAsync().GetAwaiter().GetResult();
}
}
@@ -89,13 +81,31 @@ namespace WalletWasabi.Gui
Global.CrashReporter.SetException(ex);
}
- await Global.DisposeAsync().ConfigureAwait(false);
+ await CloseAsync();
// There is no other way to stop the creation of the WasabiWindow.
Environment.Exit(1);
}
}
+ private static async Task CloseAsync()
+ {
+ var disposeGui = MainWindowViewModel.Instance is { };
+ if (disposeGui)
+ {
+ MainWindowViewModel.Instance.Dispose();
+ }
+
+ await Global?.DisposeAsync();
+ AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
+ TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
+
+ if (disposeGui)
+ {
+ Logger.LogSoftwareStopped("Wasabi GUI");
+ }
+ }
+
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Logger.LogWarning(e?.Exception);

Unify CloseAsync