Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in .NET FTP by (320 points)
I am trying to display the file download progress on a .net form. I'm using C# .NET 2.0. I have a form with progress controls on it. I have encapsulated the FTPConnection object in my own FTPManager Class of which I pass an instance to my progress form. I create a backgroundworker object on my form and in the dowork function of the backgroundworker I call ftpconnection.download. I handle the bytes transferred event in the the ftpConnection object.
I use a delegate to update the controls on my form.

Here are the problems I'm having. Any suggestions will be welcome.

1) I noticed that when I call ftpConnection from my DoWork function, my DoWork function will not continue until the file is completely downloaded. this locks out the cancel button on my form. What is the recommended way to laucnh the ftpconnection.Download command asynchrounsly?

2) I've noticed that after a while the progress controls on my form will "freeze" (not update) but the file is still being transferred and I am still getting the bytesTransferred event. Is this an improper use of the FTPconnection object or is this a windows threading problem that I need to work out?

thanks,
Ira Idelson

3 Answers

0 votes
by (162k points)
edtFTPnet/Free doesn't support asynchronous downloads, so you'll need to put the operation in a separate thread.

The other alternative is edtFTPnet/PRO which supports asynchronous operations but isn't freeware.
0 votes
by (320 points)
==>edtFTPnet/Free doesn't support asynchronous downloads, so you'll need to put the operation in a separate thread.
that's what I'm trying to do but I guess I'm not doing it correctly. where / how do I spin off a separate thread for this.. Do I Create a separate thread to hose my FTP connection object? Do I spin a separate thread for the download command? or a separate thread for the bytestransferred callback?
Can I do that with a .NET background worker or do I need to do down a level in the .NET threading model for that?

thanks,
Ira Idelson
0 votes
by (162k points)
You could do the download in a separate thread using ThreadPool.QueueUserWorkItem

Categories

...