Prevent stopping twice.
MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -27,7 +27,7 @@ namespace WalletWasabi.Wallets
{
public class Wallet : BackgroundService
{
- private WalletState _state;
+ private volatile WalletState _state;
public Wallet(string dataDir, Network network, string filePath) : this(dataDir, network, KeyManager.FromFile(filePath))
{
@@ -263,6 +263,8 @@ namespace WalletWasabi.Wallets
var prevState = State;
State = WalletState.Stopping;
+ if (prevState < WalletState.Stopping)
+ {
await base.StopAsync(cancel).ConfigureAwait(false);
if (prevState >= WalletState.Initialized)
@@ -277,6 +279,7 @@ namespace WalletWasabi.Wallets
Logger.LogInfo($"{nameof(ChaumianClient)} is stopped.");
}
}
+ }
finally
{
State = WalletState.Stopped;

Prevent stopping twice.