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 

Problem in Enable/Disable a Task

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



Joined: 10 May 2005
Posts: 5

PostPosted: Wed May 11, 2005 3:33 pm    Post subject: Problem in Enable/Disable a Task Reply with quote

Hello,

I am having problem in enabling/disabling a task. I am using the folowing code but the changes are not getting saved:

var
Index : Integer;
Task: TTaskItem;
begin
for Index := 0 to Scheduler.Count - 1 do begin
Task := Scheduler.Items[Index];
Task.Activate;
if SetActive then //SetActive is procedure parameter
Task.Flags := Task.Flags + [tfDisabled]
else
Task.Flags := Task.Flags - [tfDisabled];
Task.Save;
end;
end;


Any help will be appreciated.

thanks and regards,
Partha
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Wed May 11, 2005 7:12 pm    Post subject: Reply with quote

Do you get any error? May be using
Code:
Task.Deactivate(True);
instead of
Code:
Task.Save;
will help? How do you see that changes are not saved? Do you make "refresh"?
Back to top
View user's profile Send private message
partha



Joined: 10 May 2005
Posts: 5

PostPosted: Thu May 12, 2005 3:25 am    Post subject: Reply with quote

I tried both

Task.Deactivate(True);
and
Task.Save;

None of them work. I do not get an error but the status is not updated.

I am not displaying it to any control so I do not need a refresh.
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Thu May 12, 2005 4:20 am    Post subject: Reply with quote

This really strange. There is no any "problematic" place in your code.
Quote:
I do not get an error but the status is not updated.
But where do you "see" this status if you don't display it? Directly in Scheduled Tasks? Then Status column doesn't change on adding Disabled flag, but only Schedule and Next Run coulmns indicates Disabled.
Back to top
View user's profile Send private message
partha



Joined: 10 May 2005
Posts: 5

PostPosted: Thu May 12, 2005 4:45 am    Post subject: Reply with quote

I check directly in windows scheduler. Also with,
Task.EditWorkItem
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Thu May 12, 2005 6:22 am    Post subject: Reply with quote

Smile There is small bug in your source and I can suppose it is the origin of problem. Instead of
Code:
if SetActive then //SetActive is procedure parameter
Task.Flags := Task.Flags + [tfDisabled]
else
Task.Flags := Task.Flags - [tfDisabled];
shall be used
Code:
if SetActive then //SetActive is procedure parameter
Task.Flags := Task.Flags - [tfDisabled]
else
Task.Flags := Task.Flags + [tfDisabled];

Please let us know if this fixes the problem.
Back to top
View user's profile Send private message
partha



Joined: 10 May 2005
Posts: 5

PostPosted: Thu May 12, 2005 7:00 am    Post subject: Reply with quote

Thanks, it solves this. Smile
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