From a9d031af115032c49276f3fbfd8b935de2460ff6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 28 Feb 2019 23:56:15 +0100 Subject: [PATCH] ScheduledTasks fix possible issue if system time manual change applied --- Quick.Threads.pas | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Quick.Threads.pas b/Quick.Threads.pas index e778242..7eb271d 100644 --- a/Quick.Threads.pas +++ b/Quick.Threads.pas @@ -7,7 +7,7 @@ Author : Kike Pérez Version : 1.4 Created : 09/03/2018 - Modified : 18/02/2019 + Modified : 28/02/2019 This file is part of QuickLib: https://github.com/exilon/QuickLib @@ -1402,9 +1402,14 @@ function TScheduledTask.CheckSchedule: Boolean; tmMinutes : fNextExecution := IncMinute(fNextExecution,fTimeInterval); tmSeconds : fNextExecution := IncSecond(fNextExecution,fTimeInterval); 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;