Skip to content

Commit

Permalink
Unhandled Exception: Index was out of range. Fix
Browse files Browse the repository at this point in the history
Fix maca134#7

Why:
now=100
nextRun = 5
nextRun + 1 = 6
nextRun-now=-94 (Index out of range)

Now:
nextRun = now+next
nextRun - now (Conversion from DateTime)
  • Loading branch information
LexTheGreat committed May 5, 2018
1 parent c83c4c4 commit 9089f07
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Plugins/ScheduledTasks/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ public TimeSpan TimeSpan
{
var now = DateTime.Now;

if (now > _nextRun)
_nextRun.Add(_interval);
if (now > _nextRun) {
_nextRun = now.Add(_interval);
}
return _nextRun.Subtract(DateTime.Now);
}
}
Expand Down

0 comments on commit 9089f07

Please sign in to comment.