Threads: Remaining time

When the process starts, store the value of Microseconds in a property. At any point, you can do Var Elapsed As Double = Microseconds - Self.StartTime and you have the amount of time passed. Divide by 1000000 to turn that into a number of seconds.

Then you just need to turn the number of seconds into a string. It could be as simple as

Var Minutes As Integer = Floor(Elapsed / 60) Elapsed = Elapsed - (Minutes * 60) Var Seconds As Integer = Floor(Elapsed)

Thanks Thom. I don’t need the elapsed time, I need the remaining time. Upside-down.

I would argue that remaining time is too variable since it’s going to depend on too many things. You’re also in a thread that itself whose progress is going to vary depending on the computer and what else the user has running. The whole point of the progress bar control is to give the user a visual indicator of current progress so you don’t have to give an estimate. Anything above the progress bar is a bonus.

You do need the elapsed time in order to compute the remaining time. Your original code computes the elapsed time using absolute timestamps, and estimates the remaining time based on that. The only change I’m recommending is using relative timestamps.

Although you’re right, I did give you example code for producing a string from the elapsed time. My mistake. The logic is right, you’d just substitute the Elapsed variable for whatever you computed for the remaining time.