interface
uses KA2016.uScheduledTasks;
var ScheduledTasks: TScheduledTasks;
implementation
procedure TForm1.FormCreate(Sender: TObject); begin ScheduledTasks := TScheduledTasks.Create; ScheduledTasks.OnSchedule := ScheduledTasksOnSchedule; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ScheduledTasks.Free; end;
procedure TForm1.Button1Click(Sender: TObject); var ScheduledTaskInfo: TScheduledTaskInfo; RepeatEvery: TRepeatEvery; begin // Set some info RepeatEvery := 2; With ScheduledTaskInfo do begin Name := 'This is a test'; StartTime := Now + 5 / 86400; StopTime := ScheduledTaskInfo.StartTime + 1 / 24; RepeatType := rptMinutely; RepeatInfo := RepeatEvery; end; //Add a Schedules Task ( no limit for items to add ) ScheduledTasks.AddScheduledTask(ScheduledTaskInfo); if ScheduledTaskInfo.ID >= 0 then begin Memo1.Lines.Add('ScheduledTasks Started ' + ScheduledTaskInfo.ID.ToString); end else begin Memo1.Lines.Add('ScheduledTasks not Started'); end; end;
procedure TForm1.ScheduledTasksOnSchedule(Sender: TObject; ScheduledTaskInfo: TScheduledTaskInfo); begin Memo1.Lines.Add('ScheduledTasks.OnSchedule'); Memo1.Lines.Add('Name:' + ScheduledTaskInfo.Name); Memo1.Lines.Add('ID:' + ScheduledTaskInfo.ID.ToString); end; |