MultiThreading in Delphi FMX

  

I’m trying to iterate though a TClientDataSet and refresh a TLabel and a TProgressBar in Android, but I get this error. How can I fix it?

This is the execute procedure. is the first time i’m working wuth multithreads in Delphi and i would like to know about that.

I hope you can help me.

procedure TThreadCatalogos.Execute;
var i : Integer;
AppPath : string;
begin
AppPath := System.IOUtils.TPath.GetPublicPath;
ProgressBar.Min := 0;

for i := round(ProgressBar.Min) to round(ProgressBar.Max) do begin
// check if Self(thread) is terminated, if so exit
if Terminated then
Exit;
Position := i;

{*******************************************}

Conexion.Open;
//CLIENTES
dsClientes.Open;
//mtClientes.EmptyDataSet;
dsClientes.First;
ProgressBar.Max := dsClientes.RecordCount;
while not dsClientes.Eof do
begin
if not mtClientes.Locate(‘nombre’,dsClientes.FieldByName(‘nombre’).AsString,[]) then
begin
Synchronize(procedure()
begin
mtClientes.Insert;
mtClientes.Fields[0].Value := dsClientes.FieldByName(‘cliente_id’).Asinteger;
mtClientes.Fields[1].Value := dsClientes.FieldByName(‘nombre’).AsString;
mtClientes.Fields[2].Value := dsClientes.FieldByName(‘tipo’).AsString;
mtClientes.Post;
mtClientes.SaveToFile(System.IOUtils.TPath.combine(AppPath,’CLIENTES.bin’),sfBinary);
lbl.Text := ‘Cliente ‘+floattostr(ProgressBar.Value)+’ de ‘+floattostr(ProgressBar.Max);
ProgressBar.Value := ProgressBar.Value + 1;
end);
dsClientes.Next;
end;
//mtClientes.SaveToFile(System.IOUtils.TPath.combine(AppPath,’CLIENTES.xml’),sfXML);
mtClientes.First;

end); Exit;

end;
{************************************************}

end;
end;

Comments are closed.