FTP threads

Rusty

Well-Known Member
Licensed User
Longtime User
I have an install program that logs onto my FTP server; parses all folders and downloads all files within. Each folder found on the FTP server is replicated on the Android device. The folder "tree" is parsed all the way down creating Android folders like the FTP folders and copying all the files from the FTP server to the Android device.
My problem is that the FTP threads quickly get exhausted when downloading a large "tree" with many nodes.
Has anyone developed a similar application that is able to manage the threads so the Android OS doesn't complain?
thanks, in advance.
 

margret

Well-Known Member
Licensed User
Longtime User
FTP Folders

Hello,

You might be able to store the server folders/files you are creating to an array. Then set a timer that moves through the array one FTP process at a time. When the timer event is called, maybe once each second or half second, check for the existence of the current array path / file you are creating on the device. If it exist, increment the array position +1, the next time the timer event is called what it will be checking for is the next array's folder / file. If the array if incremented, stop the timer and call the next FTP process. In the FTP_(What ever function you use Completed), restart the timer. This way the FTP will never be doing more than a single item que. I use some code similar to this in downloading many hundreds of files and it always works fine. Hope this makes sense.

Thanks,

Margret
 
Upvote 0
Top