我在一个线程中利用indyftp和远程服务器进行数据传输
 constructor TDownThread.Create(var idftp: TIdFTP);
begin
  downftp := IdFTP;
  FreeOnTerminate := True;
  inherited Create(False);
end;destructor TDownThread.Destroy;
begin
  downftp.Disconnect;
  inherited;
end;procedure TDownThread.Execute;
begin
  { Place thread code here }
  if not terminated and downftp.connected then
  begin
    if downftp = nil then Terminate;
    if Terminated then Exit;
    try
      downftp.Get('a.rar','c:\1.rar',true);
      if terminated then exit;
    finally
      downftp.Disconnect;
      FreeAndNil(downftp);
    end;
  end;
end;
当按下暂停键时,代码为
downthread.terminate;
但是为什么根本就中止不了这个线程,从Serv-U的显示来看,仍然在进行数据传输,请问我应当怎样立即中止indyftp和远程服务器的数据传输?
谢谢

解决方案 »

  1.   

    你得代码中并没有真正做到Disconnect
    你可以考虑写一个停止下载得函数控制downftp停止,
    用一个变量做标记,是否停止,
      

  2.   

    是不是IndyFTP在Get的时候阻塞了,所以我在外边中止线程的时候没有反应呢?
     另外,为什么我的代码里面没有真正做到disconnect?
      

  3.   

    downftp.Get('a.rar','c:\1.rar',true);
          if terminated then exit;你说什么时候执行 
    if terminated then 
       exit;
    如果我这样说你都不明白那么你最好自己调试一下,设置断点,单部调试就知道怎么回事了
    你就看看exit又没有用就行了,我想这个你应该会了吧