Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Progress bar on FTP download


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-24-2008, 03:53 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default Progress bar on FTP download

Is there any way to associate a progress bar with an FTP file download?

I've got a little utility that downloads files off my server with no problems, but I'd like to find a way to show the progress of the download (so I know if I've got time to go get coffee, etc...)

Gary
Reply With Quote
  #2 (permalink)  
Old 01-24-2008, 05:11 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

It is not possible as the download method is a synchronous operation.
You can show the file size before download.
Reply With Quote
  #3 (permalink)  
Old 01-24-2008, 09:02 PM
dzt's Avatar
dzt dzt is offline
Basic4ppc Veteran
 
Join Date: May 2007
Location: Greece
Posts: 353
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Yes but now there is agraham's Threading library Threading library for optimising compiler

You can run ftp commands in a seperate thread using Thread object.

In your main thread add a timer and check the filesize of the file you are downloading

FileSize(AppPath & "\big.zip")

That's it!
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #4 (permalink)  
Old 01-26-2008, 05:33 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

Great idea, Dimitris. I'm having a small problem with the implementation, though.

I put the code that updates the progress bar into its own thread; it just crashes. Really not sure why.

Have you done anything like this sucessfully?
Reply With Quote
  #5 (permalink)  
Old 01-26-2008, 07:22 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by willisgt View Post
I put the code that updates the progress bar into its own thread; it just crashes. Really not sure why.
Are you using thread events? I tried to explain in the help that you can't update graphic controls directly in code in a thread. You must fire a thread event to do the updating for you. See the example that updates a textbox from a thread - you must do the same.
Reply With Quote
  #6 (permalink)  
Old 01-27-2008, 08:38 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

I tried to have a look at the help file you provided before I satrted working with the .dll, but with no luck. The window hust diaplys 'Action Cancelled' whnever I pull up the 'Threading' help menu option.

So I'm tying to work entirely from the example code you provided.

Yes, I put the .chm file into /basic4ppc/libraries.

(I've got to find some time to try to write a .dll - that's just so cool to be able to add on to Basic4PPC!)

Gary
Reply With Quote
  #7 (permalink)  
Old 01-27-2008, 10:34 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by willisgt View Post
I The window hust diaplys 'Action Cancelled' whnever I pull up the 'Threading' help menu option.
That's very strange. I use the same template for all my help files and just modify it each time so there should be nothing different with that particular help file. It works fine for me, and I assume dzt who has tried the library. Are any other help files affected? I suggest a Google for "Help Action cancelled" it bought up a couple of things to check.
Reply With Quote
  #8 (permalink)  
Old 01-28-2008, 12:29 AM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 154
Default

Oops... I forgot that Windows XP's internal security can block files like this. The solution (for those who don't know) is to right-click the file and click 'Unblock'. Then the contents will display correctly.

Oh, and the error I was getting was a divide by zero when calculating the progress bar's value. Had nothing to do with threading.

Now if I can just find my 'dunce' cap...

So now my code is error-free but does not update the progress bar; as you say, GUI operations are not thread-safe. So I'm still looking for a solution that will update the progress bar during an ftp file download.

I'm a beleiver that there's always a solution.

Great library, by the way!

Gary
Reply With Quote
  #9 (permalink)  
Old 01-28-2008, 10:05 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,690
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by willisgt View Post
So I'm still looking for a solution that will update the progress bar during an ftp file download.
As the FTP thread will be blocked during file transfer because it is a synchronous operation there is no way to do it from that thread unless you are downloading mutiple files when you could update progress from that thread between files.

I can't think of anyway of monitoring the progress of a synchronous process other than what dzt suggested in post #3 i.e. monitor something that is changing from the main or another thread thread. In this case, as he suggested, the size of the downloading file. However as the file is presumably open during the download I don't know if the returned size would be anything other than zero until it is closed - nor indeed whether it would locked and inaccessible. Only a trial would tell.
Reply With Quote
  #10 (permalink)  
Old 01-28-2008, 12:08 PM
Senior Member
 
Join Date: Jul 2007
Posts: 147
Awards Showcase
Beta Tester 
Total Awards: 1
Default

How does explorer display the size of the file to be downloaded and the amount thats downloaded so far? Thats what you are talking about, right?

dennishea
__________________
Using 6.30
dennishea
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change color in a progress bar 2220 Questions & Help Needed 8 09-28-2008 10:58 AM
help with download file Byak@ Questions & Help Needed 2 07-14-2008 07:14 PM
'sprite' dragging (made progress but have new problems) cpc6128 Questions & Help Needed 5 03-06-2008 01:51 PM
Low-level FTP upload with progress brathbone Open Source Projects 3 02-10-2008 12:42 PM
Vertical Progress bar davelew1s Questions & Help Needed 2 08-23-2007 07:09 PM


All times are GMT. The time now is 05:08 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0