SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Filtering task list in demo

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent
View previous topic :: View next topic  
Author Message
plumothy



Joined: 25 Oct 2010
Posts: 13

PostPosted: Tue Oct 26, 2010 12:36 pm    Post subject: Filtering task list in demo Reply with quote

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?
Back to top
View user's profile Send private message
plumothy



Joined: 25 Oct 2010
Posts: 13

PostPosted: Tue Oct 26, 2010 12:52 pm    Post subject: Reply with quote

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]);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group