private async void TaskBody() { while (true) { try { var transactions = await databaseWorker.GetNewTransactions(); if (transactions != null) { transactions = await ValidateTransactions(transactions); if (transactions.Any()) { logger.LogInformation($"Sending {transactions.Count()} transactions."); var txHash = await SendTransactions(transactions); await databaseWorker.SetTransactionStatus(transactions.Select(x => x.Id), txHash == null, txHash); } } await Task.Delay(configuration.TransactionWaitTime); } catch (Exception ex) { logger.LogError(ex, "Error in TransactionManager"); await Task.Delay(configuration.TransactionWaitTime); } } }