I'm employing Delphi 10.4 along with OmniThreadLibrary, utilizing the Parallel.ForEach construct to execute tasks. However, I'm encountering an issue where I'm only notified when all tasks have been completed. Is there a method to receive notifications when individual tasks finish, similar to the schedule mechanism or async foreach? Below is a snippet of my code for reference:
`procedure TfrmForEachOutput.MSGNewData(var msg: TOmniMessage);
begin
OutputDebugString('Finish');
end;
procedure TfrmForEachOutput.ProcessTransactions(input: TList<TSSRINTBWTH>; output: TList<TTransaction>);
var
outQueue : IOmniBlockingCollection;
transaction: TOmniValue;
begin
outQueue := TOmniBlockingCollection.Create;
Parallel.ForEach(0, input.Count - 1)
.TaskConfig(Parallel.TaskConfig.OnMessage(Self))
.NoWait
.Into(outQueue)
.Execute(
procedure(const task: IOmniTask;const value: integer; var result: TOmniValue)
begin
result := TTransaction.Create(input[value],task);
end
);
for transaction in outQueue do
begin
output.Add(transaction.AsObject as TTransaction);
end;
end;
....
....
begin
task.Comm.Send(MSG_NEWDATA, '');//this executed only when all tasks has been completed
end;`
Thank you
I tried schedule with no sucess.
