Call Environment.Exit at a better place
MODIFY
WalletWasabi.Gui/CommandLine/Daemon.cs
WalletWasabi.Gui/CommandLine/Daemon.cs
@@ -124,8 +124,6 @@ namespace WalletWasabi.Gui.CommandLine
}
// Keep this loop alive as long as a coin is enqueued or keepalive was specified.
while (keepMixAlive || AnyCoinsQueued());
-
- await Global.DisposeAsync();
}
catch
{
@@ -136,6 +134,7 @@ namespace WalletWasabi.Gui.CommandLine
}
finally
{
+ await Global.DisposeAsync().ConfigureAwait(false);
Logger.LogInfo($"{nameof(Daemon)} stopped.");
}
}

MODIFY
WalletWasabi.Gui/CommandLine/MixerCommand.cs
WalletWasabi.Gui/CommandLine/MixerCommand.cs
@@ -49,6 +49,11 @@ namespace WalletWasabi.Gui.CommandLine
}
catch (Exception ex)
{
+ if (!(ex is OperationCanceledException))
+ {
+ Logger.LogCritical(ex);
+ }
+
Console.WriteLine($"commands: There was a problem interpreting the command, please review it.");
Logger.LogDebug(ex);
error = true;

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -361,17 +361,6 @@ namespace WalletWasabi.Gui
WalletManager.RegisterServices(BitcoinStore, Synchronizer, Nodes, Config.ServiceConfiguration, FeeProviders, blockProvider);
}
- catch (Exception ex)
- {
- if (!cancel.IsCancellationRequested)
- {
- Logger.LogCritical(ex);
- }
-
- InitializationCompleted = true;
- await DisposeAsync().ConfigureAwait(false);
- Environment.Exit(1);
- }
finally
{
InitializationCompleted = true;

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -64,6 +64,8 @@ namespace WalletWasabi.Gui
}
private static async void AppMainAsync(string[] args)
+ {
+ try
{
AvalonStudio.Extensibility.Theme.ColorTheme.LoadTheme(AvalonStudio.Extensibility.Theme.ColorTheme.VisualStudioDark);
MainWindowViewModel.Instance = new MainWindowViewModel();
@@ -74,6 +76,17 @@ namespace WalletWasabi.Gui
Dispatcher.UIThread.Post(GC.Collect);
}
+ catch (Exception ex)
+ {
+ if (!(ex is OperationCanceledException))
+ {
+ Logger.LogCritical(ex);
+ }
+
+ await Global.DisposeAsync().ConfigureAwait(false);
+ Environment.Exit(1);
+ }
+ }
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{

Call Environment.Exit at a better place