Rely on HostedService start/stop.
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -160,9 +160,7 @@ namespace WalletWasabi.Gui
}
Tor.Http.TorHttpClient torHttpClient = BackendHttpClientFactory.NewTorHttpClient(Mode.DefaultCircuit);
- TorMonitor torMonitor = new(period: TimeSpan.FromSeconds(3), fallbackBackendUri: Config.GetFallbackBackendUri(), torHttpClient, TorManager);
- _ = torMonitor.StartBootstrapMonitorAsync(cancel);
- HostedServices.Register<TorMonitor>(torMonitor, nameof(TorMonitor));
+ HostedServices.Register<TorMonitor>(new TorMonitor(period: TimeSpan.FromSeconds(3), fallbackBackendUri: Config.GetFallbackBackendUri(), torHttpClient, TorManager), nameof(TorMonitor));
}
Logger.LogInfo($"{nameof(TorProcessManager)} is initialized.");

MODIFY
WalletWasabi/Tor/TorMonitor.cs
WalletWasabi/Tor/TorMonitor.cs
@@ -39,7 +39,15 @@ namespace WalletWasabi.Tor
private TorHttpClient HttpClient { get; }
private TorProcessManager TorProcessManager { get; }
- public async Task StartBootstrapMonitorAsync(CancellationToken appShutdownToken)
+ /// <inheritdoc/>
+ public override Task StartAsync(CancellationToken cancellationToken)
+ {
+ _ = StartBootstrapMonitorAsync(cancellationToken);
+
+ return base.StartAsync(cancellationToken);
+ }
+
+ private async Task StartBootstrapMonitorAsync(CancellationToken appShutdownToken)
{
using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(appShutdownToken, LoopCts.Token);
@@ -167,10 +175,11 @@ namespace WalletWasabi.Tor
}
/// <inheritdoc/>
- public override void Dispose()
+ public override Task StopAsync(CancellationToken cancellationToken)
{
LoopCts.Cancel();
- base.Dispose();
+
+ return base.StopAsync(cancellationToken);
}
}
}

Rely on HostedService start/stop.