소스 검색

Merge pull request #10 from turric4n/develop

[Quick.Threads.TScheduledTask] >> Some useful things
Exilon 6 년 전
부모
커밋
0d426f9859
2개의 변경된 파일12개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 2
      Quick.Commons.pas
  2. 10 1
      Quick.Threads.pas

+ 2 - 2
Quick.Commons.pas

@@ -466,10 +466,10 @@ begin
   path.ALLUSERSPROFILE := SysUtils.GetEnvironmentVariable('AllUsersProfile');
   path.INSTDRIVE := path.HOMEDRIVE;
   path.TEMP := SysUtils.GetEnvironmentVariable('TEMP');
-  path.SYSTEM := GetSpecialFolderPath(CSIDL_SYSTEM);
-  path.APPDATA:=GetSpecialFolderPath(CSIDL_APPDATA);
   //these paths fail if user is SYSTEM
   try
+    path.SYSTEM := GetSpecialFolderPath(CSIDL_SYSTEM);
+    path.APPDATA := GetSpecialFolderPath(CSIDL_APPDATA);
     path.DESKTOP := GetSpecialFolderPath(CSIDL_DESKTOP);
     path.DESKTOP_ALLUSERS := GetSpecialFolderPath(CSIDL_COMMON_DESKTOPDIRECTORY);
     path.STARTMENU:=GetSpecialFolderPath(CSIDL_PROGRAMS);

+ 10 - 1
Quick.Threads.pas

@@ -183,7 +183,7 @@ type
 
   TScheduleMode = (smRunOnce, smRepeatMode);
 
-  TTimeMeasure = (tmDays, tmHours, tmMinutes, tmSeconds);
+  TTimeMeasure = (tmDays, tmHours, tmMinutes, tmSeconds, tmMilliseconds);
 
   ITask = interface
   ['{0182FD36-5A7C-4C00-BBF8-7CFB1E3F9BB1}']
@@ -293,6 +293,7 @@ type
   TScheduledTask = class(TTask,IScheduledTask)
   private
     fName : string;
+    fcurrentschedule : TPair<Integer, TTimeMeasure>;
     fExecutionTimes : Integer;
     fScheduleMode : TScheduleMode;
     fTimeInterval : Integer;
@@ -308,10 +309,12 @@ type
     function CheckSchedule : Boolean;
     procedure DoExpire;
     function GetTaskName : string;
+    function GetCurrentSchedule: TPair<TTimeMeasure, Integer>;
   protected
     property ExpireWithSync : Boolean read fExpireWithSync write fExpireWithSync;
   public
     property Name : string read fName write fName;
+    property CurrentSchedule : TPair<TTimeMeasure, Integer> read GetCurrentSchedule;
     function OnException(aTaskProc : TTaskExceptionProc) : IScheduledTask; virtual;
     function OnException_Sync(aTaskProc : TTaskExceptionProc) : IScheduledTask; virtual;
     function OnTerminated(aTaskProc : TTaskProc) : IScheduledTask; virtual;
@@ -1401,6 +1404,7 @@ begin
         tmHours : fNextExecution := IncHour(fNextExecution,fTimeInterval);
         tmMinutes : fNextExecution := IncMinute(fNextExecution,fTimeInterval);
         tmSeconds : fNextExecution := IncSecond(fNextExecution,fTimeInterval);
+        tmMilliseconds : fNextExecution := IncMilliSecond(fNextExecution, fTimeInterval);
       end;
 
       if Now() > fNextExecution then Result := False //avoid execution if system time was altered
@@ -1433,6 +1437,11 @@ begin
   fEnabled := False;
 end;
 
+function TScheduledTask.GetCurrentSchedule: TPair<TTimeMeasure, Integer>;
+begin
+  Result := TPair<TTimeMeasure, Integer>.Create(fTimeMeasure, fTimeInterval);
+end;
+
 function TScheduledTask.GetTaskName: string;
 begin
   Result := fName;