Thema: Delphi Problem mit Download

Einzelnen Beitrag anzeigen

scp

Registriert seit: 31. Okt 2003
1.120 Beiträge
 
Delphi 7 Personal
 
#3

Re: Problem mit Download

  Alt 9. Jan 2004, 18:13
Woran genau es hängt, kann ich dir auch nicht sagen, aber das eine oder andere fällt mir schon auf:

1. Globale Variablen (fileinfo, speichernals,runterladen) sind für einen Thread nicht sehr günstig.
2. UpdateForm1 sollte mit Synchronize(UpdateForm1) aufgerufen werden, eben so die einzelnen bezüge auf PagesDlg2, da sie ja nicht zum aktuellen Thread gehören.
3. Du rufst in der Callback DownloadThread auf, eigentlich müsstest du der Callback den aktuellen Thread übergeben, etwa so:

Delphi-Quellcode:
type
  cDownloadStatusCallback = class(TObject,IUnknown,IBindStatusCallback)
protected
  FDownloadThread : TDownloadThread;
//...
public
  constructor Create(ADownloadThread : TDownloadThread);
//...
end;

constructor cDownloadStatusCallback.Create(ADownloadThread : TDownloadThread);
begin
  inherited Create;

  FDownloadThread := ADownloadThread;
end;
Aufruf mit:
Delphi-Quellcode:
procedure TDownloadThread.DownloadFiles;
var cDownStatus : cDownloadStatusCallback;
begin
  cDownStatus := cDownloadStatusCallBack.Create(self);
//...
Aufruf von UpdateForm1 dann so:
FDownloadThread.Synchronize(FDownloadThread.UpdateForm1);
  Mit Zitat antworten Zitat