title: destructor when stopping idhttp.get ( indy, delphi)
body: <p>My application can download one picture from every url in memo1.
  It uses idhttp.get and has a skipbutton. After skip it downloads the next picture.</p>
  
  <p><strong>Q1: Do you have code to put into the destructor and what is the  code for " terminate" and "waitfor"?</strong>
  I found this on another website:</p>
  
  <pre><code>destructor thread.destroy;
  begin
  try
  Terminate;
  If HTTP.Connected then HTTP.Disconnect;
  finally
  WaitFor;
  FreeAndNil(HTTP);
  end;
  inherited;
  end;
  </code></pre>
  
  <p><strong>Q2: How do I call the destructor and make it work?</strong></p>
  
  <p><strong>Q3: Do you have hints (especially security concerns) and additional lines of  code?</strong></p>
  
  <p>the code of my application:</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
    IdTCPClient, IdHTTP;
  
  type
         thread = class
    public
        Constructor Create; overload;
        Destructor  Destroy; override;
    end;
  
    TForm1 = class(TForm)
      IdHTTP1: TIdHTTP;
      Memo1: TMemo;
      Memo2: TMemo;
      Memo3: TMemo;
      startbutton: TButton;
      skipbutton: TButton;
  
      procedure startbuttonClick(Sender: TObject);
      procedure skipbuttonClick(Sender: TObject);
      procedure IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
        const AWorkCount: Integer);
  
           end;
  var
    Form1: TForm1;
       http: tidhttp;
       s: boolean;
  implementation
  
  {$R *.dfm}
  
              constructor thread.Create;
  begin
        HTTP := TIdHTTP.Create(nil);
        inherited ;
  end;
  
             destructor thread.destroy;
  begin
  try
  
  If HTTP.Connected then HTTP.Disconnect;
  finally
  FreeAndNil(HTTP);
  end;
  inherited;
  end;
  
  
  procedure TForm1.startbuttonClick(Sender: TObject);
  var
  i: integer;
    fs : TFileStream ;
  begin
  for i:= 0 to memo1.lines.count-1 do begin
  s:= false;
     fs := TFileStream.Create(inttostr(i)+'abc.jpg', fmCreate);
     http:= idhttp1;
     try
     try
  HTTP.Get(memo1.lines[i],fs);
  memo2.Lines.add(memo1.Lines[i]);
  except
  on E: Exception do
  begin
  memo3.lines.add(' ha ha ha not working   '+syserrormessage(getlasterror));
  end;
  end;
  finally
  fs.free;
  end;
  end;
  
    end;
  
  procedure TForm1.skipbuttonClick(Sender: TObject);
      begin
  s:=true;
  end;
  
  procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
    const AWorkCount: Integer);
  begin
  application.ProcessMessages;
  
       if s = true then
  http.Disconnect;
  
  end;
  
  end.
  </code></pre>