title: Correctly making a threaded FTP download (Indy/Android)
body: <p>I've made an IdFTP to download files from my FTP server, however when I try to make it Threaded it stuck in "Resolving hostname..." in Android OS.</p>
  
  <p>Without Thread (working fine):</p>
  
  <pre><code>uses ..., IdFTPCommon;
  
  var
    RecordDownload: TMemoryStream;
  
  uses System.IOUtils;
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    IdFTP1.Host := 'motoristaajudante.ddns.net';
    IdFTP1.Port := 2121;
    IdFTP1.DataPortMin := 50100;
    IdFTP1.DataPortMax := 51100;
    IdFTP1.Username := 'anonymous';
    IdFTP1.TransferType := IdFTPCommon.TIdFTPTransferType.ftBinary;
    IdFTP1.Passive := True;
    try
      IdFTP1.Connect();
      IdFTP1.Get('00001.m4a',TPath.GetDocumentsPath + PathDelim + '00001.m4a',True,False);
    except
      IdFTP1.Disconnect;
    end;
  end;
  
  procedure TForm1.IdFTP1AfterGet(ASender: TObject; AStream: TStream);
  begin
    IdFTP1.Disconnect;
  end;
  
  procedure TForm1.IdFTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
  begin
    if FileExists(TPath.GetDocumentsPath + PathDelim + '00001.m4a') then
    begin
        ShowMessage('Downloaded!');
    end;
  end;
  </code></pre>
  
  <p>And the Threaded code I made following <a href="https://stackoverflow.com/questions/20688839/correctly-using-taniindicator-in-firemonkey-mobile-dev-for-wait-for-processing">this solution</a> :</p>
  
  <pre><code>uses ..., IdFTPCommon;
  
  type
    TLoadThread = class(TThread)
    public
      constructor Create; reintroduce;
    protected
      procedure Execute; override;
    end;
  
  type
    TForm1 = class(TForm)
    ...
    procedure ThreadTerminated(Sender: TObject);
  
  var
    RecordDownload: TMemoryStream;
    Loading: Boolean = False;
    zLThread: TLoadThread = nil;
  
  uses System.IOUtils;
  
  constructor TLoadThread.Create;
  begin
    inherited Create(True);
    FreeOnTerminate := True;
  end;
  
  procedure TLoadThread.Execute;
  begin
  try
    Form1.IdFTP1.Connect();
    Form1.IdFTP1.Get('00001.m4a',TPath.GetDocumentsPath + PathDelim + '00001.m4a',True,False);
  except
    Form1.IdFTP1.Disconnect;
  end;
  end;
  
  procedure TForm1.ThreadTerminated(Sender: TObject);
  begin
    zLThread := nil;
    Loading := False;
    FloatAnimation1.Enabled := False;
    FloatAnimation2.Enabled := False;
    Arc3.StartAngle := -90;
    Arc3.EndAngle := 0;
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    IdFTP1.Host := 'motoristaajudante.ddns.net';
    IdFTP1.Port := 2121;
    IdFTP1.DataPortMin := 50100;
    IdFTP1.DataPortMax := 51100;
    IdFTP1.Username := 'anonymous';
    IdFTP1.TransferType := IdFTPCommon.TIdFTPTransferType.ftBinary;
    IdFTP1.Passive := True;
    zLThread := TLoadThread.Create;
    zLThread.OnTerminate := ThreadTerminated;
    zLThread.Start;
    Loading := True;
    FloatAnimation1.Enabled := True;
    FloatAnimation2.Enabled := True;
  end;
  
  procedure TForm1.IdFTP1AfterGet(ASender: TObject; AStream: TStream);
  begin
    IdFTP1.Disconnect;
  end;
  
  procedure TForm1.IdFTP1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
  begin
    Form1.FloatAnimation1.Enabled := False;
    Form1.FloatAnimation2.Enabled := False;
    Form1.Arc3.StartAngle := -90;
    Form1.Arc3.EndAngle := 0;
    if FileExists(TPath.GetDocumentsPath + PathDelim + '00001.m4a') then
    begin
        ShowMessage('Downloaded!');
    end;
  end;
  
  procedure TForm1.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus;
    const AStatusText: string);
  begin
    Memo1.Lines.Add(AStatusText);
    Application.ProcessMessages;
  end;
  </code></pre>
  
  <p>Then the FTP status show it stuck in "Resolving hostname ...". How to make it correctly threaded?</p>