Move CancelKeyPress handler to it own method for reuse
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -13,7 +13,6 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.BitcoinCore;
@@ -27,7 +26,6 @@ using WalletWasabi.Blockchain.TransactionProcessing;
using WalletWasabi.CoinJoin.Client;
using WalletWasabi.CoinJoin.Client.Clients;
using WalletWasabi.CoinJoin.Client.Clients.Queuing;
-using WalletWasabi.CoinJoin.Client.Rounds;
using WalletWasabi.Gui.Helpers;
using WalletWasabi.Helpers;
using WalletWasabi.Hwi.Models;
@@ -205,18 +203,7 @@ namespace WalletWasabi.Gui
Console.CancelKeyPress += async (s, e) =>
{
e.Cancel = true;
- Logger.LogWarning("Process was signaled for killing.");
-
- KillRequested = true;
- await TryDesperateDequeueAllCoinsAsync();
- Dispatcher.UIThread.PostLogException(() =>
- {
- var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
- window?.Close();
- });
- await DisposeAsync();
-
- Logger.LogSoftwareStopped("Wasabi");
+ await StopAndExitAsync();
};
#endregion ProcessKillSubscription
@@ -403,6 +390,22 @@ namespace WalletWasabi.Gui
}
}
+ internal async Task StopAndExitAsync()
+ {
+ Logger.LogWarning("Process was signaled for killing.", nameof(Global));
+
+ KillRequested = true;
+ await TryDesperateDequeueAllCoinsAsync();
+ Dispatcher.UIThread.PostLogException(() =>
+ {
+ var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow;
+ window?.Close();
+ });
+ await DisposeAsync();
+
+ Logger.LogSoftwareStopped("Wasabi");
+ }
+
private async Task<AddressManagerBehavior> InitializeAddressManagerBehaviorAsync()
{
var needsToDiscoverPeers = true;

Move CancelKeyPress handler to it own method for reuse