Take a look at this code-snippet. I tried to isolate it. Assume you have > 100 records in the database that match the query
FAllInProgressTasks := FManager.Find<TDatabaseTask>.
if FAllInProgressTasks.Count > 0 then
FManager.BatchSize := FAllInProgressTasks.Count;
FManager.CachedUpdates := true;
for nX := FAllInProgressTasks.Count - 1 downto 0 do
FTask := FAllInProgressTasks.Items[nX];
FTask.TaskState := tsRestart;
FManager.CachedUpdates := false; // If you don't turn off CachedUpdates here the second run will fail and generate an exception
FReady := true;
If you dont set the CachedUpdates to false after ApplyUpdates, the second time it will fail and generate an exception.