public async Task ExecuteAsync() { _log.Info("Executing the job..."); var from = await _balanceService.TryGetLatestSnapshotTimestampAsync() ?? await _balanceService.TryGetFirstBalanceUpdateTimestampAsync(); if (from != null) { var to = _dateTimeProvider.UtcNow; var missedExecutions = _createBalanceSnapshotCron.GetOccurrences ( fromUtc: from.Value + _createBalanceSnapshotDelay, toUtc: to, fromInclusive: false, toInclusive: true ).ToList(); _log.Info("Context", new { from, to, missedExecutions }); foreach (var missedExecution in missedExecutions) { to = missedExecution - _createBalanceSnapshotDelay; await _balanceService.CreateSnapshotAsync(from.Value, to); from = to; } _log.Info("Done"); } else { _log.Info("No balance snapshots have been created. 'from' is null"); } }