Filtering task list in demo

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
plumothy
Posts: 16
Joined: Mon Oct 25, 2010 8:24 pm

Filtering task list in demo

Post by plumothy »

I am trying to filter the task list in the demo app by testing Task properties in acRefreshExecute. But every time I try to access a task property (like Task.ApplicationName or Task.Status) I get a runtime error.

Like this:
procedure TMainForm.acRefreshExecute(Sender: TObject);
var
Task: TTaskItem;
Item: TListItem;
Index: Integer;
begin
ListView.Items.Clear;
Scheduler.Refresh;
for Index := 0 to Scheduler.Count - 1 do
begin
Task := Scheduler.Items[Index];
// if (Task.<SomeProperty> = <SomeValue>) then begin // error happens here
Item := ListView.Items.Add;
Item.Caption := Task.Name;
Item.Data := Task;
UpdateListItem(Item);
//end;
end;
pnlTarget.Caption := Format(' Scheduled tasks on %s',
[Scheduler.TargetComputer]);
end;

Can anyone tell me how to find out the name of the scheduled application in this method so I can only add the ones that I want?

plumothy
Posts: 16
Joined: Mon Oct 25, 2010 8:24 pm

Post by plumothy »

My apologies everyone. I have now seen how to do it. The task must be activated first like this:

procedure TMainForm.acRefreshExecute(Sender: TObject);
var
Task: TTaskItem;
Item: TListItem;
Index: Integer;
begin
ListView.Items.Clear;
Scheduler.Refresh;
for Index := 0 to Scheduler.Count - 1 do
begin
Task := Scheduler.Items[Index];
Task.Activate;
if (Task.ApplicationName = 'MyTaskName' ) then begin
Item := ListView.Items.Add;
Item.Caption := Task.Name;
Item.Data := Task;
UpdateListItem(Item);
end;
end;
pnlTarget.Caption := Format(' Scheduled tasks on %s',
[Scheduler.TargetComputer]);

Post Reply