Einzelnen Beitrag anzeigen

ozz

Registriert seit: 26. Jun 2005
131 Beiträge
 
#9

Re: Thread.Terminated erzeugt unbekannter Bezeichner

  Alt 6. Jan 2007, 22:30
Hallo Sunlight7,
ja, ich habe eine Klasse davon abgeleitet.Gib es noch etwas zu beachten?

Delphi-Quellcode:
unit HttpGetThreads;

interface

uses
  Classes,
  IdBaseComponent, IdComponent,IdTCPConnection,IdTCPClient, IdHTTP,IdObjs;//Indy
type
  TMyHttpThreads = class(TThread)

  private
  IdHTTP: TIdHTTP;
  ContentStream:TStringStream;
  FURL:string;
  FTerminated:Boolean;
  procedure loadComplete;

  public
    property ActualURL: String read FURL;
    property Terminated:Boolean read FTerminated;
  protected
    procedure Execute; override;
  end;

implementation
uses JobQueueMultiThread;//Main

procedure TMyHttpThreads.Execute;
var loop:Integer;
begin
 try
 FTerminated:=False;
 IdHTTP:=TIdHTTP.Create;

  while ((JobQueue.Joblist.Count>0) and Terminated=false) do
  begin;
   FURL:=JobQueue.Joblist.Strings[0];
   JobQueue.Joblist.Delete(0);

   ContentStream:= TStringStream.Create(toEOF);
   try
   IdHTTP.Get(FURL,ContentStream);
   except
    on e:EIdHTTPProtocolException do
        begin
          JobQueue.Joblist.Add(FURL);
        end;
   end;

   ContentStream.Seek(0, soFromBeginning);
   Synchronize(loadComplete);

   ContentStream.Destroy;
  end;
 finally
  FTerminated:=True;
  IdHTTP.Destroy;
  if Assigned (ContentStream) then ContentStream.Destroy;
 end;
end;

procedure TMyHttpThreads.loadComplete;
begin
 JobQueue.ThreadResult(ContentStream);
end;

end.
  Mit Zitat antworten Zitat