|
-
Sep 7th, 2009, 12:23 AM
#1
Thread Starter
Fanatic Member
Calculate estimate time...
Hey,
I have an app that encrypts a file, and I would like to have an estimate of the time remaining, but I don't know how. Any ideas will be greatly appreciated!
Thanks a lot .
-
Sep 7th, 2009, 12:35 AM
#2
Member
Re: Calculate estimate time...
Try to use Progress Bar if possible.
-
Sep 7th, 2009, 12:36 AM
#3
Thread Starter
Fanatic Member
Re: Calculate estimate time...
I already have a progressbar, I just wanted to add that to be more "specific", but I have found out it's inaccurate, so I guess I'll stick to the progressbar though. However, if you have any idea, still let me know, I want to know .
-
Sep 7th, 2009, 12:40 AM
#4
Member
Re: Calculate estimate time...
Ummm....better and great idea is to use only progress bar because it's manages the work remaining in its own way....still we can look for new way if anyone else know
-
Sep 7th, 2009, 06:46 AM
#5
Hyperactive Member
Re: Calculate estimate time...
Quoted from a moderator at the MSDN forum:
Get a timestamp when you start the process
DateTime starttime = DateTime.Now;
To calculate the remaining time you will get the time spent so far
TimeSpan timespent = DateTime.Now - starttime;
From the total amount of seconds spent and the progressbar you can calculate as estimate of what remains.
int secondsremaining = (int)(timespent.TotalSeconds / progressBar1.Value * (progressBar1.Maximum - progressBar1.Value));
The time spent divided per item already processed multiplied by the items remaining will give a estimate close to reality if the amount of time per item is not fluctuating too much.
For performance and to be less sensitive for fluctuations it is probably best to update at regular intervals and not after each item has been processed.
I used progressBar1 properties to demonstrate how it connect to the progressbar, actual implementation probably should not do it like that but internal counters and limits instead.
EDIT: Fixed a type TimeStamp is not what I meant, changed to TimeSpan
It is written in C# syntax but I'm sure you can understand the concept.
-
Sep 7th, 2009, 08:11 AM
#6
Re: Calculate estimate time...
 Originally Posted by arithforu
Ummm....better and great idea is to use only progress bar because it's manages the work remaining in its own way....still we can look for new way if anyone else know 
The progress bar does absolutely nothing on its own. You have to tell it when to increase, what its maximum value is etc. It doesnt 'manage' anything, its just a control that you have to command to work in the way you want to.
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
|