Ver Mensaje Individual
  #1  
Antiguo 21-09-2020
amadis amadis is offline
Miembro
 
Registrado: may 2005
Ubicación: San José, Colón, Entre Ríos, Argentina
Posts: 315
Reputación: 20
amadis Va por buen camino
Question Thread Firemonkey Android query

Que tal compañeros.

Estoy tratando de hacer funcionar un query Firedac (Sqlite). que toma datos de un clientdataset remoto.

Estoy tratando de aplicar este ejemplo de thread.

Código Delphi [-]
AniIndicator1.Enabled := True;
  Timer1.Enabled := True;
  Button1.Enabled := False;

  TThread.CreateAnonymousThread(procedure
    const
      Max = 20;
    begin
      for var i := 1 to Max do
      begin
        DoSomething(i);
        TThread.Synchronize(TThread.Current, procedure
          begin
            Progress := i * 100 div Max;
          end);
      end;
      TThread.Synchronize(TThread.Current, EndProgress);
    end).Start;


Pero cuando le pongo lo que necesito dentro NO FUNCIONA, NO SE EJECUTA

Este es el código que pretendo hacer funcionar

Código Delphi [-]
    
            QryRec := TFDQuery.Create(NIL);
                        QryRec.Connection := datos.FDconmovil;
                       QryRec.Transaction := datos.FDTrans;
                       QryRec.Connection.StartTransaction;
                      datos.CDSVende.IndexFieldNames := 'ID; COBRADOR';
                      datos.CDSVende.First;
                      max := datos.CDSVende.RecordCount;

                    TThread.CreateAnonymousThread(procedure

                      begin
                        for  i := 1 to Max do
                        begin

                          QryRec.Close;
                          QryRec.SQL.Clear;
                          QryRec.SQL.Append('INSERT INTO VENDEDOR');
                          QryRec.SQL.Append('(ID, VENDEDOR)');
                          QryRec.SQL.Append('values(:id, :v) ');
                          QryRec.ParamByName('id').AsInteger := datos.CDSVendeID.VALUE;
                          QryRec.ParamByName('v').AsString :=  datos.CDSVendeCOBRADOR.Value;
                          QryRec.ExecSQL;
                          datos.CDSVende.Next;


                          TThread.Synchronize(TThread.Current, procedure
                            begin
                              Progress := i * 100 div Max;
                              Label1.Text := inttostr(i); // esta linea es a fin de prueba para saber si corre y pues NO CORRE
                            end);
                        end;
                        TThread.Synchronize(TThread.Current, fin);
                      end).Start;


                      QryRec.Connection.Commit;
                      QryRec.free;

Si no pongo nada antes del primer TThread.Synchronize si corre.

¿que me estoy salteando u olvidando??
Responder Con Cita