DeleteTrigger issue

This forum is designated to discuss SiComponents Scheduling Agent.
Post Reply
yeohray
Posts: 10
Joined: Fri Jan 27, 2012 3:23 am

DeleteTrigger issue

Post by yeohray »

Running on Windows XP, when a task has more than 1 trigger, deleting any trigger except the last one will generate OLE error 80004005. E.g.

- task has 3 triggers
- run DeleteTrigger(0) to delete the first trigger
- deactivate task
- OLE error 80004005 is raised

or

- task has 3 triggers
- run DeleteTrigger(1) to delete the second trigger
- deactivate task
- OLE error 80004005 is raised

I tried saving the changes immediately after deleting the trigger, and this seems to resolve the issue, but I don't know for sure if this is the right way to go about it.

Before:
procedure TTriggers.Delete(Index: Integer);
begin
if not Self.FTaskItem.FTaskManager.RunningVistaOrLater then
begin
with FTaskItem.FInterface as ITask do
OleCheck(DeleteTrigger(Word(Index)));
Items[Index].Free;
end
else
FTaskItem.FTaskDefinition.Triggers.Remove(Word(Index+1));
end;


After:
procedure TTriggers.Delete(Index: Integer);
begin
if not Self.FTaskItem.FTaskManager.RunningVistaOrLater then
begin
with FTaskItem.FInterface as ITask do
OleCheck(DeleteTrigger(Word(Index)));

with FTaskItem.FInterface as IPersistFile do
OleCheck(Save(nil, True));

Items[Index].Free;
end
else
FTaskItem.FTaskDefinition.Triggers.Remove(Word(Index+1));
end;

yeohray
Posts: 10
Joined: Fri Jan 27, 2012 3:23 am

Post by yeohray »

Look like I should have done the following instead:

- task has 3 triggers
- run DeleteTrigger(0) to delete the first trigger
- save task
- deactivate trigger

Post Reply