private void DoWork(object state) { var count = Interlocked.Increment(ref executionCount); // _logger.LogInformation("BackgroundService Main Loop Count: {Count}", count); if (count == 1) { //do the following iteration only once since it'll //Block and wait for the next item in the Cached Collection foreach (var item in _idtpCache.GetCollection()) { DBUtility.SimpleInsert(item); } } }
private void DoWork(object state) { var count = Interlocked.Increment(ref executionCount); _logger.LogInformation("Timed Hosted Service is working. Count: {Count}", count); //read and output value from Cache //var cachedValue = _idtpCache.GetValue(); //_logger.LogInformation("Cached Value: {Value}", cachedValue.ToString()); foreach (var item in _idtpCache.GetCollection()) { _logger.LogInformation("Cached Value: {Value}", item.ToString()); } }