HangfireIO / HangfireIO/Cronos
Sometimes GetNextOccurrence returns a past occurrence (but very close to now)
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 137
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 1
Description
Hi, here my simplified code :
```csharp
CronExpression expression = CronExpression.Parse("0 4 * * *");
DateTimeOffset now = DateTimeOffset.Now;
DateTimeOffset? next = _cronInfo.Expression.GetNextOccurrence(now, TimeZoneInfo.Local);
if (next.HasValue)
_timer.Interval = (next.Value - now).TotalMilliseconds; //_timer is System.Timers.Timer
```
Most of the time, it's ok, but sometimes I have **System.ArgumentException** because of an invalid interval value:
`System.ArgumentException: Invalid value '-0,0091' for parameter 'interval'.`
`System.ArgumentException: Invalid value '-0,0006' for parameter 'interval'.`
`System.ArgumentException: Invalid value '-0,0037' for parameter 'interval'.`
I's always a negative value very close to zero !
I found a way around, but I was wondering how it was possible to have a negative value (i.e. earlier than the date given as parameter) ?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.