I’m developing an android app in delphi, where i dynamically create and populate Listviews. As the listviews can contain thousands of entries, freeing all the components can be time consuming, so to keep responsetime down, i want to do it in a background thread, but this causes access violations to occur.
type
TLVDirectory = record
FListView: TListViewEx;
..
end;
var
LVDir: TLVDirectory;
LVDirectories: TList<TLVDirectory>;
begin
LVDir.FListView := TListViewEx.Create(Self);
LVDir.FListView.Parent := Layout2;
LVDir.FListView.Align := TAlignLayout.Client;
LVDirectories.Add(LVDir);
.
end;
Freeing
LVDir := LVDirectories[LVDirectories.Count – 1];
LVDirectories.Delete(LVDirectories.Count – 1);
TThread.CreateAnonymousThread(procedure()
begin
LVDir.FListView.Parent := nil;
LVDir.FListView.DisposeOf;
end).Start;
How can i make this work?