i need to trigger hosted service at certain time, eg. everyday at 13:00 o'clock. Mine typical ExecuteAsync method seems like that:
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var interval = _configuration.IntervalInSeconds * 1000;
while (!stoppingToken.IsCancellationRequested)
{
// some job
await Task
.Delay(interval, stoppingToken);
}
}
When the application starts, the executeAsync method is called, and then some action is taking place every minute for example. Now i have to perform such an action only on certain hour. Is there any method to achieve such a behavior?? Is there any solution to my problem apart from rough calculating the next trigger time?? Thanks for any help.
