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
Problem in Enable/Disable a Task
Do you get any error? May be using instead of will help? How do you see that changes are not saved? Do you make "refresh"?
Code: Select all
Task.Deactivate(True);
Code: Select all
Task.Save;
This really strange. There is no any "problematic" place in your code.
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.I do not get an error but the status is not updated.

Code: Select all
if SetActive then //SetActive is procedure parameter
Task.Flags := Task.Flags + [tfDisabled]
else
Task.Flags := Task.Flags - [tfDisabled];
Code: Select all
if SetActive then //SetActive is procedure parameter
Task.Flags := Task.Flags - [tfDisabled]
else
Task.Flags := Task.Flags + [tfDisabled];