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 :D.
Printable View
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 :D.
Try to use Progress Bar if possible.
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 ;).
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 ;)
Quoted from a moderator at the MSDN forum:
It is written in C# syntax but I'm sure you can understand the concept. ;)Quote:
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