fix: use interval option

This commit is contained in:
Stevan Freeborn
2024-09-06 17:44:53 -05:00
parent 79764a484f
commit 0b264656a0
@@ -16,11 +16,14 @@ public class OnspringWorker(
{ {
_logger.LogInformation("Onspring worker started"); _logger.LogInformation("Onspring worker started");
using var scope = _serviceScopeFactory.CreateScope();
var onspringOptions = scope.ServiceProvider.GetRequiredService<OnspringOptions>();
_timer = _timeProvider.CreateTimer( _timer = _timeProvider.CreateTimer(
callback: async _ => await RunSearchRequests(), callback: async _ => await RunSearchRequests(),
state: null, state: null,
dueTime: TimeSpan.Zero, dueTime: TimeSpan.FromMinutes(onspringOptions.SearchIntervalInMinutes),
period: TimeSpan.FromMinutes(1) period: TimeSpan.FromMinutes(onspringOptions.SearchIntervalInMinutes)
); );
return Task.CompletedTask; return Task.CompletedTask;