我在一个线程中利用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和远程服务器的数据传输?
谢谢
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和远程服务器的数据传输?
谢谢
解决方案 »
- dbgrideh单元格事件问题
- 下辈子要当作曲家~~
- 多条记录对多个图像的处理(在线等,谢谢各位高手)
- 关于CreateOleObject('SQLDMO.SQLServer')且Connect后,判断连接的状态
- 高手大哥们,小弟问一个简单问题,关于检测系统是否已经安装某软件问题
- 求助【Integer(Pointer(Self))、Integer(@Self)、Self.Handle】三者的区别?
- 请教关于画图指令的问题
- 请问有没有天津塘沽的朋友???????
- Delphi6出中文版了?真的吗?
- 分享贴: delphi WIN32 Service 中启动另一个进程 (win7 win2003下测试通过)
- 为什么我的FastReport3.14不能增加多个自定义函数??
- 当ADOCommand.CommandText过长的时候,ADOCommand.Execute执行报错?
你可以考虑写一个停止下载得函数控制downftp停止,
用一个变量做标记,是否停止,
另外,为什么我的代码里面没有真正做到disconnect?
if terminated then exit;你说什么时候执行
if terminated then
exit;
如果我这样说你都不明白那么你最好自己调试一下,设置断点,单部调试就知道怎么回事了
你就看看exit又没有用就行了,我想这个你应该会了吧