Results 1 to 6 of 6

Thread: Calculate estimate time...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    Question 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 .
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  2. #2
    Member
    Join Date
    Sep 2009
    Posts
    36

    Re: Calculate estimate time...

    Try to use Progress Bar if possible.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Location
    Dominican Republic
    Posts
    733

    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 .
    "In our profession, precision and perfection are not a dispensable luxury, but a simple necessity."
    Niklaus E. Wirth


    Rate any post that helped you, it's a good way of saying thanks
    Please specify your Visual Studio Version!

    Why rating is useful

    My Code Bank Submissions: How to determine Windows Version| Working With Mouse Events | Blocking Input Using API | Get host's IP | Minimize to system tray "animated" | Colored ListBox (custom fonts, colors, highlight) Updated -New Class! | [VS 2008] Strong encryption and hashing class - Updated! 31/August/2009 | Create a shortcut using IWshRuntimeLibrary

  4. #4
    Member
    Join Date
    Sep 2009
    Posts
    36

    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

  5. #5
    Hyperactive Member BadgerBadger's Avatar
    Join Date
    Aug 2009
    Location
    Wales
    Posts
    382

    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.

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Calculate estimate time...

    Quote Originally Posted by arithforu View Post
    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.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width