OmniThreadLibrary icon indicating copy to clipboard operation
OmniThreadLibrary copied to clipboard

ForEach not working for objects?

Open thetoolwiz opened this issue 4 years ago • 0 comments

I have a TListView and I'm doing this to iterate over the Items in it:

  FWorker := Parallel.ForEach<TListItem>( lview1.Items );

  FWorker.Execute(
            procedure( const task: IOmniTask; const aLI : TListItem )
            begin
            . . . . 

I get this error:

First chance exception at $75CBB5B2. Exception class Exception with message 'TValue of type tkClass cannot be converted to TOmniValue'. Process ThreadingTest2VCL.exe (8516)

in procedure OtlCommon.TOmniValue.SetAsTValue(const value: TValue);

If I change it to a pointer, that fails as well, I'm guessing because the iterator returns an object.

Is this a bug, or "as designed"?

thetoolwiz avatar Dec 28 '21 00:12 thetoolwiz