TIdAntiFreeze and TIdFTP problem.

Hi all,
        I'm using a TIdAntiFreeze component in my FTP client to allow users
to be able to cancel transfers or functions however I noticed that whenever
I have the Antifreeze component on the for the application doesn't freeze up
but I'm still unable to cancel a transfer or operation. It seems to also
prevent me from doing multiple file transfers using the following function:

Function TMain.Downloadfiles(Filename, Destination: String; Fileaction:
TFileActionSet): Boolean;
Var e, i, l: Integer; StreamHandle, Streamsize: Longint;
Begin
Result:= False;
file://Download one or more files from the Files:TStringslist.
If not FTP.Connected Then Exit;

If TransferringData then Exit;

Streamsize:=0;
BytesToTransfer:= 0;
For l:=0 to Ftp.DirectoryListing.Count-1 do If Extractfilename(Filename) =
Ftp.DirectoryListing.Items[l].Filename Then BytesToTransfer :=
Ftp.DirectoryListing.Items[l].Size-Streamsize;

TS:= BytesToTransfer-Streamsize;

{Deals with Overwrite, Resume and Skip}
If FileExists(Destination) Then
Begin
StreamHandle:=FileOpen(Destination, fmopenread);
Streamsize:=Getfilesize(Streamhandle, nil);
Fileclose(streamhandle);
BytesToTransfer:= BytesToTransfer - Streamsize;
TS:= BytesToTransfer;
If (AutoAction = Integer(faNone)) {and (Fileaction= faNone)} Then
Begin
ExistsBox.Caption:= Destination;
ExistsBox.FLabel.Caption:='Filename: '+Extractfilename(Destination);
ExistsBox.SLabel.Caption:='File Size:
'+IntToStr(BytesToTransfer+Streamsize)+' bytes';
ExistsBox.TYLabel.Caption:='Transfer Type: Download.';
ExistsBox.BLabel.Caption:='Bytes already aquired: '+IntToStr(Streamsize)+'
bytes';
file://Find out ahead of time if resume is supported by the server.
ExistsBox.Resumebtn.Enabled:= FTP.CanResume;
Existsbox.ShowModal;
Fileaction:= Main.FileAction;
end;
end; {Deals with Overwrite, Resume and Skip}

Case FileAction of
faNone: Begin
        file://FTP.TransferType := ftBinary;
        Case Transfermode of
        0: FTP.TransferType := ftBinary;
        1: FTP.TransferType := ftASCII;
        2: FTP.TransferType := ftBinary;
        end;
        FTP.Get(Filename, Destination, False, False);
        end;
faOverwrite: Begin
             file://FTP.TransferType := ftBinary;
             Case Transfermode of
             0: FTP.TransferType := ftBinary;
             1: FTP.TransferType := ftASCII;
             2: FTP.TransferType := ftBinary;
             end;
             FTP.Get(Filename, Destination, True, False);
             end;
faResume: Begin
          file://FTP.TransferType := ftBinary;
          Case Transfermode of
          0: FTP.TransferType := ftBinary;
          1: FTP.TransferType := ftASCII;
          2: FTP.TransferType := ftBinary;
          end;
          FTP.Get(Filename, Destination, False, True);
          end;
faSkip: ;
Else
Begin
file://FTP.TransferType := ftBinary;
Case Transfermode of
 0: FTP.TransferType := ftBinary;
 1: FTP.TransferType := ftASCII;
 2: FTP.TransferType := ftBinary;
end;
FTP.Get(Filename, Destination, False, False);
end;
end;
Result:=True;
end;

Function TMain.Uploadfiles(Files, Destination: TStrings; Fileaction:
TFileActionSet): Boolean;
Var i, l: Integer; CD: String; StreamHandle, Streamsize: Longint;
Begin
Result:= False;
CD:=Remotedir.Text;
file://Upload one or more files from the Files:TStringslist.
If not FTP.Connected Then Exit;

For i:=0 to Files.Count-1 do
Begin
StreamHandle:= FileOpen(Files.Strings[i], fmopenread);
Streamsize:= Getfilesize(Streamhandle, nil);
Fileclose(streamhandle);
BytesToTransfer:= Streamsize;
TS:= BytesToTransfer;
For l:=0 to FTP.DirectoryListing.Count-1 do
If Extractfilename(Files.Strings[i]) =
FTP.DirectoryListing.Items[l].FileName Then
Begin
BytesToTransfer:= Streamsize-FTP.DirectoryListing.Items[l].Size;
TS:= BytesToTransfer;

If (AutoAction = Integer(faNone)) {and (Fileaction= faNone)} Then
Begin
ExistsBox.Caption:= Extractfilename(Files.Strings[i]);
ExistsBox.FLabel.Caption:='Filename: '+Extractfilename(Files.Strings[i]);
ExistsBox.SLabel.Caption:='File Size: '+IntToStr(Streamsize)+' bytes';
ExistsBox.TYLabel.Caption:='Transfer Type: Upload.';
ExistsBox.BLabel.Caption:='Bytes already aquired:
'+IntToStr(FTP.DirectoryListing.Items[l].Size)+' bytes';
ExistsBox.Resumebtn.Enabled:= FTP.CanResume;
Existsbox.ShowModal;
Fileaction:= Main.FileAction;
end;
end;

Case FileAction of
faNone..faOverwrite:
        Try
         Case Transfermode of
         0: FTP.TransferType := ftBinary;
         1: FTP.TransferType := ftASCII;
         2: FTP.TransferType := ftBinary;
         end;
         file://Ftp.ChangeDir(Destination.Strings[i]);
         FTP.Put(Files.Strings[i], ExtractFilename(Files.Strings[i]),
False);
        Finally
        end;
faResume:
         Begin
           Try
           Case Transfermode of
           0: FTP.TransferType := ftBinary;
           1: FTP.TransferType := ftASCII;
           2: FTP.TransferType := ftBinary;
           end;
             file://Ftp.ChangeDir(Destination.Strings[i]);
             FTP.Put(Files.Strings[i], ExtractFilename(Files.Strings[i]),
True);
            Finally
            end;
            end;
faSkip:
        Begin
        end;
Else
        Begin
        Try
         Case Transfermode of
         0: FTP.TransferType := ftBinary;
         1: FTP.TransferType := ftASCII;
         2: FTP.TransferType := ftBinary;
         end;
         file://Ftp.ChangeDir(Destination.Strings[i]);
         FTP.Put(Files.Strings[i], ExtractFilename(Files.Strings[i]),
False);
        Finally
        end;
        end;
end;
end;
Files.Clear;
Destination.Clear;
Ftp.ChangeDir(CD);
Result:=True;
End;

procedure TMain.Download1Click(Sender: TObject);
Var
  CPath, Name: String;
  Files, Dirs: TStringlist;
  I, q: Integer;
  ItemData: TListitem;
begin
  if not FTP.Connected then exit;
  If not Remotelist.Items[Remotelist.ItemIndex].Selected Then Exit;

  CPath:= LDirectory.Directory;
  Prevdir:= Remotedir.Text;
  Name := RemoteList.Selected.Caption;
  I:= Remotelist.Items[Remotelist.ItemIndex].Index;
  file://Change directory up if the selection ".."
  If name = '..' then Begin Ftp.ChangeDirUp; Exit; end;
  if FTP.DirectoryListing.Items[I].ItemType = ditDirectory then begin
  // Change directory
   ChageDir(Name);
  end
  else
{  if FTP.DirectoryListing.Items[I].ItemType = ditSymboliclink Then
  Begin
  If Extractfileext(Name) <> '' Then
  Name:=FTP.DirectoryListing.Items[i].FileName;
  Files.Add(Name);
  Dirs.Add(CPath+Name);
  Downloadfiles(Files, Dirs, Fileaction);
   end
  else
  Begin
   ChageDir(FTP.DirectoryListing.Items[i].FileName);
  end;

Quote
}

  if FTP.DirectoryListing.Items[I].ItemType = ditFile then
  Begin
  {Name:=FTP.DirectoryListing.Items[i].FileName;
  Downloadfiles(Name, CPath+Name, FileAction);}
  Files:= TStringlist.Create;
  Dirs:= TStringlist.Create;
  begin
  For i:=0 to Remotelist.Items.Count-1 do
  Begin
  If Remotelist.Items[i].Selected Then
  Begin
  Name:=FTP.DirectoryListing.Items[i].FileName;
  Files.Add(Name);
  Dirs.Add(CPath+Name);
  end;
  end;
  For i:=0 to Files.Count-1 do Downloadfiles(Files.Strings[i],
Dirs.Strings[i], FileAction);
  end;
  end;
  Loadlist;
end;

However if I want to transfer only a single file it then works just fine.
Whenever I remove the AntiFreeze component, I'm then able to do multiple
transfers, but I lose control of the application and it seems to have frozen
even though the transfer is still taking place.

In the OnWork Event I have the following code:

Function TMain.ETA(Total, Rate: LongWord): String;
var
tempTime     : TDateTime;  { temporary time value }
Begin
 { calculate time values }
    TempTime:= Now - StartTime;  { elapsed time }
    file://Result:= TimeToStr(tempTime); { elapsed time }
    file://Result:= TimeToStr(tempTime / (Rate + 1)* Total); { estimated
time }
    Result:= FormatDateTime('hh:mm:ss', (tempTime - tempTime / (Rate + 1)*
Total)); { estimated time left }
end;

procedure TMain.FTPWork(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCount: Integer);
Var
  S, D: String;
  TotalTime, MT: TDateTime;
  H, M, Sec, MS, i: Word;
  DLTime: Double;
begin

  TotalTime :=  Now - STime;
  DecodeTime(TotalTime, H, M, Sec, MS);
  Sec := Sec + M * 60 + H * 3600;
  DLTime := Sec + MS / 1000;
  if DLTime > 0 then
  AverageSpeed := (AWorkCount / 1024) / DLTime;
  If BytesToTransfer <>0 Then

  S := FormatFloat('0.00 KB/s', AverageSpeed);
  D:=ETA(BytesToTransfer, AWorkCount);

  case AWorkMode of
  wmRead: StatBar.Panels[1].Text := 'Download Time Remaining '+ D + ' @ ' +
S;
  wmWrite: StatBar.Panels[1].Text := 'Upload Time Remaining '+ D + ' @ ' + S
;
  end;

  if AbortTransfer then
  Begin
   FTP.Abort;
   StatBar.Panels[1].Text := 'Transfer Aborted';
  end;

  GBar.Progress := AWorkCount;
  Main.Caption:= 'AssasynFTP'+' Transfer '+IntToStr(GBar.PercentDone)+'%
Completed';
  CTray.Hint := Main.Caption;
  AbortTransfer := false;
end;

procedure TMain.FTPWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCountMax: Integer);
begin
  TransferringData := true;
  AbortBtn.Enabled := true;
  AbortBtn.Visible := true;
  AbortTransfer := false;

  LTree.Enabled:=False;
  Remotelist.Enabled:=False;
  LDirectory.Enabled:=False;
  Remotedir.Enabled:= False;

  STime := Now;
  Starttime:=Now;
  if AWorkCountMax > 0 then GBar.MaxValue := AWorkCountMax
  else GBar.MaxValue := BytesToTransfer;
  AverageSpeed := 0;
  BytesTransferred:= 0;
  Main.Caption:= 'AssasynFTP'+' Connected to '+FTP.Host+'
['+FTP.SystemDesc+']';
  CTray.Hint := Main.Caption;
end;

procedure TMain.FTPWorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
  AbortBtn.Enabled := false;
  AbortBtn.Visible := false;
  StatBar.Panels[1].Text := 'Transfer complete.';
  BytesToTransfer := 0;
  TransferringData := false;
  GBar.progress := 0;
  AverageSpeed := 0;
  TS := 0;
  DT := 0;
  Remotelist.Enabled:= True;
  LDirectory.Enabled:= True;
  LTree.Enabled:= True;
  Remotedir.Enabled:= True;
  Main.Caption:= 'AssasynFTP'+' Connected to '+FTP.Host+'
['+FTP.SystemDesc+']';
  CTray.Hint := Main.Caption;
end;

Any help would be greatly appreciated.

Thanks
Daynier.