BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIdFTP.Get in thread

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Seldon
Guest





PostPosted: Thu May 03, 2007 10:53 pm    Post subject: TIdFTP.Get in thread Reply with quote



I call TIdFTP.Get method in thread:

constructor
TFtpThread.Create(FTPProgressForm:TFTPProgressForm;FTPClient:TIdFTP;
const FTPFileName,HDDFileName:String;Download:Boolean);
begin
fFTPProgressForm:=FTPProgressForm;
fFTPClient:=FTPClient;
fFTPFileName:=FTPFileName;
fHDDFileName:=HDDFileName;
fDownload:=Download;

inherited Create(false);
end;

procedure TFtpThread.Execute;
begin
try
try
if fDownload then
fFTPClient.Get(fFTPFileName,fHDDFileName)
else
fFTPClient.Put(fHDDFileName,fFTPFileName)
except
on E:EIdException do
begin
fErr:=E.Message;
Synchronize(NotifyError);
end;
end;
finally
Synchronize(NotifyDone);
end;
end;

procedure TFtpThread.NotifyDone;
begin
fFTPProgressForm.HandleDone;
end;

procedure TFtpThread.NotifyError;
begin
fFTPProgressForm.HandleFTPError(fErr);
end;

I pass to Create TIdFTP placed on the form. Is it a good idea?
I use thread instead of TIdAntiFreeze because when I written these code,
TIdAntiFreeze was broken. Now it seems to be fine. So maybe I must use
TIdAntiFreeze, not thread?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri May 04, 2007 5:33 am    Post subject: Re: TIdFTP.Get in thread Reply with quote



"Seldon" <nospam (AT) nospam (DOT) com> wrote in message
news:op.trrim6agl3jomk@seldon...

Quote:
I pass to Create TIdFTP placed on the form. Is it a good idea?

It is fine, as long as the TIdFTP object remains alive in memory while
the thread is running, and no other thread is using the TIdFTP at the
same time.

Quote:
I use thread instead of TIdAntiFreeze

A wise decision.

Quote:
So maybe I must use TIdAntiFreeze, not thread?

I would not recommend using TIdAntiFreeze. Using a thread is fine.


Gambit
Back to top
Seldon
Guest





PostPosted: Sat May 05, 2007 12:07 am    Post subject: Re: TIdFTP.Get in thread Reply with quote



OK, fine.
Another question: can I call TIdFTP.Abort from the main thread (i.e. from
event handler)?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat May 05, 2007 2:16 am    Post subject: Re: TIdFTP.Get in thread Reply with quote

"Seldon" <nospam (AT) nospam (DOT) com> wrote in message
news:op.trtgqqzpl3jomk@seldon...

Quote:
can I call TIdFTP.Abort from the main thread (i.e. from event
handler)?


I would not recommend it. Then you have two threads accessing the
same socket potentially at the same time. I would suggest using
TIdFTP's OnWork events instead for calling Abort().


Gambit
Back to top
Seldon
Guest





PostPosted: Sat May 05, 2007 3:54 am    Post subject: Re: TIdFTP.Get in thread Reply with quote

Quote:
I would suggest using TIdFTP's OnWork events instead for calling
Abort().
but how can I abort downloading/uploading by the OnWork event? it

declaration in my version of Indy (10.1.6 - dev snapshot, I have download
some days ago):
TWorkEvent = procedure(ASender: TObject; AWorkMode: TWorkMode; AWorkCount:
Int64) of object;
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat May 05, 2007 4:02 am    Post subject: Re: TIdFTP.Get in thread Reply with quote

"Seldon" <nospam (AT) nospam (DOT) com> wrote in message
news:op.trtq8idil3jomk@seldon...

Quote:
but how can I abort downloading/uploading by the OnWork event?

Like I said, simply call Abort() in the event handler. Assign the
event handler to the TIdFTP before you download/upload your files, and
then have the event handler check whatever condition you need to
signal when an abort should take place.

Quote:
it declaration in my version of Indy:
snip


And the problem is...?


Gambit
Back to top
Seldon
Guest





PostPosted: Sat May 05, 2007 2:54 pm    Post subject: Re: TIdFTP.Get in thread Reply with quote

Quote:
simply call Abort() in the event handler
thx, it works.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.