You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) ?
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. This is a bug, since it's not expected that next execution will be less than the given one. Trying to reproduce the behavior.
Hi, here my simplified code :
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.TimerMost 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) ?
The text was updated successfully, but these errors were encountered: