|
-
Jan 26th, 2002, 04:16 PM
#1
Thread Starter
New Member
Showing Progress with API Functions...
This is a rather simple piece of code, but I am trying to do something and am not even sure if it is possible.
Here is the code that I am using...
Code:
connect_status.Text = "•Transferring file as ASCII; " & output & vbCrLf & connect_status.Text
DoEvents
flestat = FtpGetFile(hConnection, output, _
main.queue.ListItems(startQueueDownload).Text, False, &H80000000, _
INTERNET_FLAG_TRANSFER_ASCII, 0)
This code downloads a file from an FTP server. I want to have a progress bar or some other means of monitoring the download progress of this file. Unfortunately, the API call will not update its status until it has completely downloaded the file.
Does anyone have any ideas of how I could go about preparing a progress bar to calculate the amount of data that has been sent in the middle of this API call. This could be accomplished by getting the local filesize of the downloaded file, but I need to find a way to temporarily pause the API function while the program calculates the amount of the file that has been downloaded.
Thanks,
Shawn
-
Jan 26th, 2002, 07:54 PM
#2
Toss a DoEvents in there.
-
Jan 26th, 2002, 08:08 PM
#3
Thread Starter
New Member
Unfortunately, DoEvents doesn't work because the code already completes the API command before proceeding
-
Jan 26th, 2002, 08:22 PM
#4
Hmm....good point.
Ok, how 'bout this.
.Wav files are typically called asynchroniously so the program can continue processing while the sound file is playing. How about asynchroniously popping a form with a progress bar?
Now, if you can determine the size of the file before processing starts, so much the better. If you can't, then fake as best you can. If you have ever watched the microsoft download status progress bar, you get the feeling thats what they do.
-
Jan 27th, 2002, 12:03 AM
#5
Thread Starter
New Member
I have the exact filesize in bytes before it begins transfer, but the problem lies in that a timer for example will only execute once when the process is running, this at the absolute beginning or end of the API call. I do not know how to go about resolving this issue, but is is quite important.
Thanks for your help,
Shawn
-
Jan 28th, 2002, 04:39 PM
#6
Swinging in the dark here, but if you know the exact size of the
file could you invoke the API to download only a certain number
of bytes (say 10%) and then update the progress bar in
iterations?
Code:
While byte_Num < full_byte_Num
call api(byte_num to next_byte_num)
update progress bar
set byte_num = next_byte_num
wend
Don't even know if it can be done, but seems logical.
-
Jan 28th, 2002, 11:53 PM
#7
Member
I have created a small FTP tool, and was looking at putting something similar (Some sort of progress indicator) into mine. At the moment, the App seems a bit dead while the FTP is happening, it even reports Not Responding from Task manager.
I am using the API FtpPutFile (with DoEvents just before it), and I am seeing the same thing, you get nothing back from the API till it either finishes, or dies for some reason.
Currently I set the mouse cursor to hourglass, and hope the user doesnt get too impatient and kill my app while the FTP is going
-
Feb 3rd, 2002, 08:32 PM
#8
Member
A post I read elsewhere by Shawn N is a good idea.....
What if you used multi-threading, either create a new thread to perform the FTP API, or perhaps to monitor the progress of the API running from your main thread !!
I guess that periodically you could check the file size of the file you are getting (or putting), and compare that to the total file size....
hmmm I wonder if it will let me get the file size of a the mainframe dataset I am uploading.....
-
Feb 5th, 2002, 01:10 AM
#9
Member
Well the API guide tells me that Multiple threads is going to crash my VB6 Application...
I know C++ can use multiple threads... anyone care to share some wisdom ??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|