Когда нужно отобразить прогресс. Пробовал разными способами и потоками и чем угодно, но получилось вот так, через Syncronize. Анализируйте код. Это работает !)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
procedure TSyncFrame.bStartClick(Sender: TObject); var d: TDreamHTTP2; s: TSyncDM; N: Integer; I: Integer; procedure UpdateClient(Val: Integer); begin ProgressBar.Position := Val; lStatus.Caption := Format('%d Progress...', [Val]); end; begin UniSession.Synchronize(); bStart.Enabled := false; // ProgressBar.Min := 1; ProgressBar.Max := 100; bStart.Enabled := False; // UniButton2.Enabled := True; UpdateClient(0); // Reset Progressbar and Label UniSession.Synchronize; // Initial refresh before entering the loop (Progressbar and Label will be refreshed) InputParamsValidation(); s := FSync; //TSyncDM.Create(nil); try s.fdconnection := UniMainModule.DB.FDConnection; // FDConnection; s.InternalTableName := eInternal_table.Text; //'table2'; s.UserID := 'SomeUserID'; s.Password := 'SomePassword'; s.Application_Access_Version := 'SomeApplication_Access_Version'; s.FromDate := dtpFromDate.DateTime; s.ToDate := dtpToDate.DateTime; s.publicIP := 'localhost'; s.IsCancel := false; s.init(); s.OnSync := OnSync; s.execute(); finally bStart.Enabled := true; // s.Free(); end; end; |
и ещё
1 2 3 4 5 6 7 8 9 10 11 12 |
procedure TSyncFrame.OnSync(aStage: string; aProgressInPercent: integer); begin if UniSession.Synchronize(500) then begin UniSession.Synchronize; // Initial refresh before entering the loop (Progressbar and Label will be refreshed) lStatus.Caption := aStage; ProgressBar.Position := aProgressInPercent; UniMemo.Lines.Clear(); UniMemo.Lines.Add('>' + aStage + ' ' + aProgressInPercent.ToString()); UniSession.Synchronize; // Initial refresh before entering the loop (Progressbar and Label will be refreshed) end; end; |