Prevent NRE on NBxplorer listener

This commit is contained in:
nicolas.dorier 2019-11-21 14:27:57 +09:00
parent 2b9f390c64
commit b915544798
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -385,10 +385,13 @@ namespace BTCPayServer.Payments.Bitcoin
}
public async Task StopAsync(CancellationToken cancellationToken)
{
leases.Dispose();
_Cts.Cancel();
await Task.WhenAny(_RunningTask.Task, Task.Delay(-1, cancellationToken));
Logs.PayServer.LogInformation($"{this.GetType().Name} successfully exited...");
if (_Cts != null)
{
leases.Dispose();
_Cts.Cancel();
await Task.WhenAny(_RunningTask.Task, Task.Delay(-1, cancellationToken));
Logs.PayServer.LogInformation($"{this.GetType().Name} successfully exited...");
}
}
}
}