DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Measure Time Remaining Of A Process

  1. #1
    Join Date
    Sep 2005

    Question Measure Time Remaining Of A Process

    Hi All

    I have a but of trouble and would like to know how to measure time remaining of a process, like copying a large file or any other lenghty process.

    For example:

    FolderCount = Text1.text
    For I = 1 to FolderCount
    Label1.caption = <time remaining>
    MkDir "Test Folder" + " " + FolderCount
    Next I

    Suppose you have many folders to create, then how can I display, in a label, the time to completethe entire operation, during the loop, in minutes and seconds? I want to have the process count down in minutes and seconds (maybe hours too) from how long it will take initially to zero time at the end. For example the Windows copy dialog that counts down the time to copy file(s) from a start time the process will take to completion of zero seconds.

    Someone suggested I should use the following code, however it seems to count up or just display to total extimated time during the entire process and does not reach zero at the end:

    Dim StartTime As Date, ElapsedTime As Date, EstimatedTotalTime As Date, EstimatedTimeRemaining As Date
    Dim TimePerIteration As Double
    Dim I As Long, FolderCount As Long

    FolderCount = Text1.Text
    StartTime = Date + Time

    For I = 1 To FolderCount
    ElapsedTime = (Date + Time - StartTime)
    TimePerIteration = ElapsedTime / I
    EstimatedTotalTime = CDate((FolderCount * TimePerIteration))
    EstimatedTimeRemaining = EstimatedTotalTime - ElapsedTime
    Label1.Caption = "Estimated Time Remaining = " & EstimatedTimeRemaining

    MkDir "Test Folder" & " " & I

    Next I

    Any help with this will be truly appreciated.

    Thankx a million

  2. #2
    Join Date
    Nov 2003
    Portland, OR
    There's no way to accurately count down in minutes and seconds; how do you determine how long it will take to copy each folder? The Windows copy dialog merely displays an estimate; have you noticed that sometimes it counts up? (See for more information.)

    You can, however, display the percent complete: Calculate the total number of files to be copied. After every, say, 10 files copied, display the value of (FilesCopied / TotalFilesToCopy) * 100 in the label.
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Sep 2005

    Measure Time Remaining Of A Process

    Phil Weber

    Thank you for your reply.

    I guess I will measure the time (with GetTickCount) 1 to 2 in For I = 1 to TotalNumber and then multiply the result with TotalNumber - 1. Letís see
    what happens, I am just interested in a vague result.

    Have a good day


Similar Threads

  1. Getting user inactivity time in a process
    By chan_fookmun in forum .NET
    Replies: 0
    Last Post: 05-11-2005, 12:13 AM
  2. Getting results from a Process in VB.NET
    By ecaslake in forum .NET
    Replies: 6
    Last Post: 04-20-2005, 10:23 AM
  3. ?API NT Compatability?
    By Dennis in forum VB Classic
    Replies: 10
    Last Post: 02-15-2001, 04:52 AM
  4. SELECT statement and time format
    By JeffM in forum Database
    Replies: 2
    Last Post: 02-06-2001, 06:21 PM
  5. How to Incrase Process response time ?
    By Saheb Bothe in forum Web
    Replies: 1
    Last Post: 05-08-2000, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center