Einzelnen Beitrag anzeigen

Benutzerbild von TheMiller
TheMiller

Registriert seit: 19. Mai 2003
Ort: Gründau
2.480 Beiträge
 
Delphi XE7 Architect
 
#6

Re: [Indy 10] IOHandler hinzufügen

  Alt 4. Apr 2009, 12:04
Naja, was soll denn da nicht stimmen? Hier mal der Code. (Mit Indy 9 hatte alles noch wunderbar funktioniert)

Achso: Der Download findet in einem Thread statt.

Die Zuweisung für das OnWork-Ereignis (Hauptprogramm / Main-Thread)

UpdateDownloader.OnWork:=OnThreadWork; Die Progressbars

Delphi-Quellcode:

//Prozeduren-Kopf in private
procedure OnThreadWork(Sender: TThread; const AWorkCount: Integer);

procedure TForm4.OnThreadWork(Sender: TThread; const AWorkCount: Integer);
begin
  Progressbar1.Position:=AWorkCount;
  Progressbar2.Position:=geladen+AWorkCount;
  //Bringt nix:
  //Progressbar1.Refresh;
  //Progressbar2.Refresh;
end;

Im DownloadThread

Delphi-Quellcode:

TOnWorkEvent = procedure(Sender: TThread; const AWorkCount: Integer) of object;

TDownloadUpdates = class(TThread)
  private
    procedure InternalOnWork(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
    procedure DoNotifyWork;
  published
    property OnWork: TOnWorkEvent read FOnWorkEvent write FOnWorkEvent;
  end;

procedure TDownloadUpdates.InternalOnWork(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
begin
  FWorkCount:=AWorkCount;
  Synchronize(DoNotifyWork);
end;

procedure TDownloadUpdates.DoNotifyWork;
begin
  if (Assigned(OnWork)) then
    OnWork(Self, FWorkCount);
end;
Das hat so alles funktioniert. Ich hoffe, ich habe alles Wichtige jetzt kopiert.
  Mit Zitat antworten Zitat