Skip to content

Commit 9b30f3b

Browse files
committed
WIP work
1 parent 9a7ad14 commit 9b30f3b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/WIP/stdCallableScheduler.bas

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ End Sub
1616
'Call all scheduled callbacks
1717
'@protected
1818
Public Sub protCallScheduledCallbacks()
19+
Dim vCurTime: vCurTime = Now()
20+
1921
Dim i As Long
2022
For i = scheduledCallbacks.Count To 1 Step -1
2123
Dim cb As stdICallable: Set cb = scheduledCallbacks(i)(0)
2224
Dim onTime As Date: onTime = scheduledCallbacks(i)(1)
23-
If onTime < Now() Then
25+
If DateDiff("s", onTime, vCurTime) >= 0 Then
2426
Call scheduledCallbacks.Remove(i)
25-
Call cb.Run()
27+
'Allow the callback to reschedule itself if needed
28+
Dim iSeconds As Long: iSeconds = cb.Run()
29+
If iSeconds > 0 Then Call ScheduleCallback(cb, iSeconds)
2630
End If
2731
Next
2832
End Sub

0 commit comments

Comments
 (0)