public BackgroundWorkerContinuation Work(BackgroundWorkerContext context, CancellationToken token) { var logEntry = new HeartbeatLogEntry(Time.UtcNow); foreach (IHeartbeatProvider provider in _providers) { logEntry.CollectFrom(provider, token); } _repository.Insert(logEntry); return(context.Wait(_interval)); }
public void Insert(HeartbeatLogEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } var configuration = _service.Get <HeartbeatLog>(); configuration.Cleanup( (int)ReadMaximumEntries().GetValueOrDefault(500u), ReadMaximumAge().GetValueOrDefault(TimeSpan.FromDays(14))); configuration.Add(_machineName, entry); _service.Save(configuration, GetType().Name); }