Board index » delphi » TIdFTP, TIdAntiFreeze, multy Thread

TIdFTP, TIdAntiFreeze, multy Thread

Hi and sorry about my english,

I wondering to write robust FTP client because site from where need to
download sometimes is ... can say weird ...

any ftp client or my client (indy) download as well till moment when packets
don't come, sometimes this freeze, just not receiving packet and not exit
from get

TIdAntiFreeze help this because I can periodicaly check last received packet
and can restart this but ... questions :

1. If I made this in TThread is any thread need to have own TIdAntiFreeze,
or this need to be only one in Application

2. TThread Question :
How I can kill Thread if this never finish Execute ?
MyThread.Terminate; from main Thread don't kill thread and TIdFtp continue
download, what i doing wrong ?

 

Re:TIdFTP, TIdAntiFreeze, multy Thread


Quote
> 1. If I made this in TThread is any thread need to have own TIdAntiFreeze,
> or this need to be only one in Application

If you put it in threads, you don't need TIdAntiFreeze at all. It's just for
avoiding blocks of the GUI when using Indy in the main thread

Quote
> 2. TThread Question :
> How I can kill Thread if this never finish Execute ?
> MyThread.Terminate; from main Thread don't kill thread and TIdFtp continue
> download, what i doing wrong ?

You need to abort the downloading manually.
Terminate only sets a flag, but does not interrupt anything. Call terminate
and then call TIdFTP.Abort or TIdFTP.Quit, or maybe even TIdFTP.CloseSocket.
But the thread will only terminate, if Execute has been completely executed.
So, your execute procedure should either look like (pseudo-code):

begin
// do stuff
TidFTP.Download
//maybe some cleanup, but nothing that blocks
end

It is your task to make the thread finish the execute procedure.
There are way of interrupting threads manually, but that should not be used
as the normal way of terminating a thread.

Andy

Re:TIdFTP, TIdAntiFreeze, multy Thread


Quote
> If you put it in threads, you don't need TIdAntiFreeze at all. It's just
for
> avoiding blocks of the GUI when using Indy in the main thread

> > 2. TThread Question :
> > How I can kill Thread if this never finish Execute ?
> > MyThread.Terminate; from main Thread don't kill thread and TIdFtp
continue
> > download, what i doing wrong ?
> You need to abort the downloading manually.
> Terminate only sets a flag, but does not interrupt anything. Call

terminate

Tnx, this help, I just solve problem, this is stable, now can lost a time on
user interface :)))

Other Threads