2
0
Эх сурвалжийг харах

ScheduledTasks fix possible issue if system time manual change applied

Unknown 6 жил өмнө
parent
commit
a9d031af11

+ 9 - 4
Quick.Threads.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.4
   Version     : 1.4
   Created     : 09/03/2018
   Created     : 09/03/2018
-  Modified    : 18/02/2019
+  Modified    : 28/02/2019
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -1402,9 +1402,14 @@ begin
         tmMinutes : fNextExecution := IncMinute(fNextExecution,fTimeInterval);
         tmMinutes : fNextExecution := IncMinute(fNextExecution,fTimeInterval);
         tmSeconds : fNextExecution := IncSecond(fNextExecution,fTimeInterval);
         tmSeconds : fNextExecution := IncSecond(fNextExecution,fTimeInterval);
       end;
       end;
-      fLastExecution := Now();
-      Inc(fExecutionTimes);
-      Result := True;
+
+      if Now() > fNextExecution then Result := False //avoid execution if system time was altered
+      else
+      begin
+        fLastExecution := Now();
+        Inc(fExecutionTimes);
+        Result := True;
+      end;
     end;
     end;
   end;
   end;
 end;
 end;