private void UncleanShutdown() { // Ensure that the wallet process is not left running in the background // (which can cause issues when starting the application a second time). // If the wallet was opened over RPC, attempt to close it first if the // client connection is still active. try { var walletClient = WalletRpcClient; if (walletClient == null) { return; } if (_walletLoaded) { Task.Run(walletClient.CloseWallet).Wait(); } } catch (Exception) { } finally { WalletRpcProcess?.KillIfExecuting(); } }
private void CleanShutdown() { // Cancel all outstanding requests and notification streams, // close the wallet if it was loaded, disconnect the client // from the process, and stop the process. var walletClient = WalletRpcClient; walletClient.CancelRequests(); Task.Run(async() => { if (_walletLoaded) { await walletClient.CloseWallet(); } await walletClient.Disconnect(); }).Wait(); walletClient.Dispose(); WalletRpcProcess.KillIfExecuting(); }