18 lines
718 B
C#
18 lines
718 B
C#
namespace QuestionsApi.Services;
|
|
|
|
public sealed class CreditLedgerReconciliationService(
|
|
CreditStore credits,
|
|
ILogger<CreditLedgerReconciliationService> logger) : BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
try { await credits.ReconcilePendingAsync(stoppingToken); }
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) { return; }
|
|
catch (Exception exception) { logger.LogError(exception, "Credit ledger reconciliation failed."); }
|
|
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken);
|
|
}
|
|
}
|
|
}
|