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
  #11 (permalink)  
Old 01-28-2008, 01:07 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by dennishea View Post
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?
The answer to this is bit more complicated than you might think. The following is simplified, and perhaps not entirely correct, but hopefully it provides some sort of explanation.

Many .NET/Operating System functions are available in both synchronous and asynchronous form. B4PPC offers only the synchronous forms for simplicity.

Synchronous operations basically block the caller until they either succeed or fail, so they need no further management by the caller. Thus they are simple to use and that is why B4PPC restricts itself to them.

Asynchronous operations in comparison need ongoing management by the caller. Typically they involve calling a function to get things going which launches a separate thread and registers a "callback function" or event that the thread calls to handle the completion of the operation. The caller is then free to do other things and when the completion event occurs must call a finalise function to get the data from the operation thread and tidy things up.

Crucially however, in order to monitor progress the, in this case FTP, process must be written with the ability to report on its' progress, via another callback, if used asynchronously. The .NET FTP functions do not do this. Explorer is probably using either its' own FTP process built on top of the OS TCP/IP stack, or is using a lower level OS facility that does provide progress monitoring.
Reply With Quote
  #12 (permalink)  
Old 01-28-2008, 01:18 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

Before posting for the first time in this topic I had made a successful test (desktop only)
__________________
Dimitris Zacharakis
http://www.terracom.gr
Reply With Quote
  #13 (permalink)  
Old 01-28-2008, 03:31 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 487
Awards Showcase
Beta Tester 
Total Awards: 1
Default

It's just an idea and not very reliable but....
If you know the size of the file to be downloaded and have a rough idea of the rate at which it transfers then you could just make a 'best guess' and use a timer to set the update of the progress bar.

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #14 (permalink)  
Old 01-28-2008, 04:03 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 164
Default Got it!

Okay - first approach was to download the file in the main code and use the thread to update the progress bar. Didn't work for reasons explained previously in this thread.

So i tried turning it around - if only the main thread can update the GUI, then use the main code to update the progress bar, and use the thread to download the file.

Bingo!

Reply With Quote
  #15 (permalink)  
Old 01-28-2008, 04:29 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
use the main code to update the progress bar, and use the thread to download the file
Yes, I think this is what dzt intially suggested and what we thought you were trying to do. It never even crossed my mind that you were trying the other way round

Quote:
Originally Posted by dzt View Post
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
Reply With Quote
  #16 (permalink)  
Old 01-28-2008, 05:18 PM
Senior Member
 
Join Date: Jul 2007
Posts: 152
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks Agraham for the reply. I think I have a grasp of what your saying.

dennishea
__________________
Using 6.30
dennishea
Reply With Quote
  #17 (permalink)  
Old 01-28-2008, 05:22 PM
willisgt's Avatar
Senior Member
 
Join Date: Aug 2007
Location: Nacogdoches, Texas USA
Posts: 164
Default

Looking back, that's exactly what Dimitris suggested.

Could've saved myself a lot of grief if I'd read it a little more closely (and fully grasped the problem at the outset).

Guess that's one of those little gaps between concept and implementation...

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 07:22 PM.


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