make dequeing more reliable in case of regtest
MODIFY
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
WalletWasabi.Gui/Dialogs/CannotCloseDialogViewModel.cs
@@ -54,22 +54,26 @@ namespace WalletWasabi.Gui.Dialogs
bool last = false;
while (!last)
{
- last = DateTime.Now - start > TimeSpan.FromMinutes(1);
+ last = DateTime.Now - start > TimeSpan.FromMinutes(2);
try
{
await Global.DesperateDequeueAllCoinsAsync();
+ last = true;
}
catch (Exception ex)
{
if (last) throw ex;
- await Task.Delay(2000, token); //wait, maybe the situation will change
+ await Task.Delay(5000, token); //wait, maybe the situation will change
}
}
_cancelTokenSource.Cancel();
Dispatcher.UIThread.Post(() =>
{
- Close();
- Application.Current.MainWindow.Close();
+ try
+ {
+ Global.QuitApplication();
+ }
+ catch (Exception) { }
});
}
catch (Exception ex)

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -73,6 +73,7 @@ namespace WalletWasabi.Gui
public static Config Config { get; private set; }
public static UiConfig UiConfig { get; private set; }
+ public static bool IsQuitPending { get; private set; }
public static void InitializeConfig(Config config)
{
@@ -356,6 +357,24 @@ namespace WalletWasabi.Gui
Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.", nameof(Global));
}
+ public static void QuitApplication()
+ {
+ if (IsQuitPending) return;
+ IsQuitPending = true;
+ try
+ {
+ if (ChaumianClient != null)
+ ChaumianClient.IsQuitPending = true;
+ Application.Current.MainWindow.Close();
+ }
+ finally
+ {
+ if (ChaumianClient != null)
+ ChaumianClient.IsQuitPending = false;
+ IsQuitPending = false;
+ }
+ }
+
public static async Task DisposeAsync()
{
try

MODIFY
WalletWasabi.Gui/Shell/Commands/ExitCommands.cs
WalletWasabi.Gui/Shell/Commands/ExitCommands.cs
@@ -21,7 +21,7 @@ namespace WalletWasabi.Gui.Shell.Commands
private void OnExit()
{
- Application.Current.MainWindow.Close();
+ Global.QuitApplication();
}
}
}

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -27,6 +27,7 @@ namespace WalletWasabi.Services
{
public Network Network { get; }
public KeyManager KeyManager { get; }
+ public bool IsQuitPending { get; set; }
private ClientRoundRegistration DelayedRoundRegistration { get; set; }
@@ -238,7 +239,7 @@ namespace WalletWasabi.Services
}
await DequeueCoinsFromMixNoLockAsync(State.GetSpentCoins().ToArray());
-
+ if (IsQuitPending) await DequeueAllCoinsFromMixNoLockAsync();
CcjClientRound inputRegistrableRound = State.GetRegistrableRoundOrDefault();
if (!(inputRegistrableRound is null))
{
@@ -682,6 +683,7 @@ namespace WalletWasabi.Services
public async Task QueueCoinsToMixAsync(params SmartCoin[] coins)
{
+ if (IsQuitPending) throw new InvalidOperationException("Quit pending - cannot enqueue coins");
await QueueCoinsToMixAsync(SaltSoup(), coins);
}

make dequeing more reliable in case of regtest