I'm trying to do a small proof of concept sample based on the second example on the section 3.12.2.2 ... Enumerable collections of your book
The main difference: instead a TStringList I'm using a TObjectList.
The code ( typed here, I hope i didn't miss anything ) :
var opsInfo : TObjectList<TMyClass>; Begin opsInfo := nil; Try opsInfo := TObjectList<TMyClass>.Create(True); for var i := 1 to 10 do opsInfo.Add( TMyClass.Create(i) ); Parallel.ForEach(opsInfo) .NumTasks(4) .Execute( procedure (const value: TOmniValue) var anInstance: TMyClass; begin anInstance := value.AsObject as TMyClass; ProcessInstance( anInstance.Field1, anInstance.Field2); end); finally FreeAndNil(opsInfo); end; End;
Executing that snippet, I get an assertion error on TOmniParallelLoopBase.Create here:
FGetCurrent := rt.GetMethod('GetCurrent');
Assert(assigned(FGetCurrent));
FGetCurrent is nil, hence the error.
I'm testing on Delphi 10.3, I think I'm using OTL version 1.53b, I searched on the open/closed issues here, I'm hesitant to upgrade the OTL to the latest, but I'm open to suggestions.
Regards
Edit: The code looks ugly, I couldn't find how to preserve new lines
Hi,
I'm trying to do a small proof of concept sample based on the second example on the section 3.12.2.2 ... Enumerable collections of your book
The main difference: instead a TStringList I'm using a TObjectList.
The code ( typed here, I hope i didn't miss anything ) :
var opsInfo : TObjectList<TMyClass>; Begin opsInfo := nil; Try opsInfo := TObjectList<TMyClass>.Create(True); for var i := 1 to 10 do opsInfo.Add( TMyClass.Create(i) ); Parallel.ForEach(opsInfo) .NumTasks(4) .Execute( procedure (const value: TOmniValue) var anInstance: TMyClass; begin anInstance := value.AsObject as TMyClass; ProcessInstance( anInstance.Field1, anInstance.Field2); end); finally FreeAndNil(opsInfo); end; End;
Executing that snippet, I get an assertion error on TOmniParallelLoopBase.Create here: FGetCurrent := rt.GetMethod('GetCurrent'); Assert(assigned(FGetCurrent));FGetCurrent is nil, hence the error.
I'm testing on Delphi 10.3, I think I'm using OTL version 1.53b, I searched on the open/closed issues here, I'm hesitant to upgrade the OTL to the latest, but I'm open to suggestions.
Regards
Edit: The code looks ugly, I couldn't find how to preserve new lines