diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj
index be6029bbe..f63079e43 100644
--- a/BTCPayServer/BTCPayServer.csproj
+++ b/BTCPayServer/BTCPayServer.csproj
@@ -2,7 +2,7 @@
Exe
netcoreapp2.0
- 1.0.0.9
+ 1.0.0.10
diff --git a/BTCPayServer/Services/Invoices/InvoiceWatcher.cs b/BTCPayServer/Services/Invoices/InvoiceWatcher.cs
index 86a655345..7c1d57f13 100644
--- a/BTCPayServer/Services/Invoices/InvoiceWatcher.cs
+++ b/BTCPayServer/Services/Invoices/InvoiceWatcher.cs
@@ -281,12 +281,12 @@ namespace BTCPayServer.Servcices.Invoices
{
Logs.PayServer.LogInformation("Start watching invoices");
ConcurrentDictionary> updating = new ConcurrentDictionary>();
- try
+ foreach(var item in _WatchRequests.GetConsumingEnumerable(_Cts.Token))
{
- foreach(var item in _WatchRequests.GetConsumingEnumerable(_Cts.Token))
+ try
{
+ _Cts.Token.ThrowIfCancellationRequested();
var localItem = item;
-
// If the invoice is already updating, ignore
Lazy updateInvoice = new Lazy(() => UpdateInvoice(localItem), false);
if(updating.TryAdd(item, updateInvoice))
@@ -294,26 +294,23 @@ namespace BTCPayServer.Servcices.Invoices
updateInvoice.Value.ContinueWith(i => updating.TryRemove(item, out updateInvoice));
}
}
- }
- catch(OperationCanceledException) when(_Cts.Token.IsCancellationRequested)
- {
- try
+ catch(OperationCanceledException) when(_Cts.Token.IsCancellationRequested)
{
- Task.WaitAll(updating.Select(c => c.Value.Value).ToArray());
+ try
+ {
+ Task.WaitAll(updating.Select(c => c.Value.Value).ToArray());
+ }
+ catch(AggregateException) { }
+ _RunningTask.TrySetResult(true);
+ break;
+ }
+ catch(Exception ex)
+ {
+ Logs.PayServer.LogCritical(ex, "Error in the InvoiceWatcher loop");
+ _Cts.Token.WaitHandle.WaitOne(2000);
}
- catch(AggregateException) { }
- _RunningTask.TrySetResult(true);
- }
- catch(Exception ex)
- {
- _Cts.Cancel();
- _RunningTask.TrySetException(ex);
- Logs.PayServer.LogCritical(ex, "Error in the InvoiceWatcher loop");
- }
- finally
- {
- Logs.PayServer.LogInformation("Stop watching invoices");
}
+ Logs.PayServer.LogInformation("Stop watching invoices");
}