Using the OmniThreadLibrary and Delphi XE4, I am hoping to run multiple threads that process data in the background, adding speed increases to my already existing code.
When calling the procedure below, the Application GUI stops processing any input until all of the threads have completed. My understanding is that using .NoWait
should allow the procedure to exit even when the threads are running.
procedure Test(input: TStringList; output: TList<TMaintFore>);
var
outQueue: IOmniBlockingCollection;
transaction: TOmniValue;
begin
outQueue := TOmniBlockingCollection.Create;
Parallel.ForEach(0, input.Count - 1)
.NoWait
.Into(outQueue)
.Execute(
procedure(const value: integer; var result: TOmniValue)
begin
result := TMaintFore.Create(input[value]);
end
);
end;
Is my understanding of the ForEach loop incorrect, suggesting I should use an alternate method to achieve background processing? Any suggestions on the correct use of the OmniThreadLibrary is appreciated.