So macht es mehr oder weniger was ich wollte, nun werden nach und nach die icons geladen und dargestellt unabhängig vom mainthread.
Delphi-Quellcode:
procedure TfrmMain.StartIcons3();
begin
TThread.CreateAnonymousThread(procedure ()
var
LIcon: TIcon;
dummy: Word;
I: Integer;
begin
FileIcons.BeginUpdate;
LIcon := TIcon.Create;
LIcon.Transparent := True;
lvFiles.Column[0].MinWidth := 37;
lvFiles.Column[0].MaxWidth := 37;
lvFiles.Column[0].Width := 37;
lvFiles.SmallImages := FileIcons;
try
for i := 0 to lvFiles.Items.Count -1 do
begin
dummy := 0;
TThread.Synchronize (TThread.CurrentThread,
procedure ()
begin
LIcon.Handle := ExtractAssociatedIcon( hInstance, PWideChar( lvFiles.Items.Item[ i ].Caption ), dummy );
end);
LIcon.Transparent := True;
dummy := FileIcons.AddIcon( LIcon );
DestroyIcon( LIcon.Handle );
TThread.Synchronize (TThread.CurrentThread,
procedure ()
begin
lvFiles.Items.Item[ i ].ImageIndex := dummy;
end);
end;
finally
TThread.Synchronize (TThread.CurrentThread,
procedure ()
begin
FileIcons.EndUpdate;
end);
LIcon.Free;
end;
end).Start;
end;