Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Estimated time remaining, what am I missing?

Tags:

c#

I think my logic is flawed....

in a loop I have:

int seconds = (int) (elapsed.TotalSeconds / ItemPos) * (Count - ItemPos);

this loop updates approximately once per second....

the problem I have is that seconds always ends up with a zero (0) value.

this is because the ItemPos value is always higher after first loop than elapsed.TotalSeconds.

So for example:

if 3 seconds pass

ItemCount = 20 , so 3/20 = 0.15 - rounds to zero.... 0 * anything = 0......

What am I doing wrong?

like image 851
JL. Avatar asked Jul 15 '13 16:07

JL.


People also ask

Why does my iPhone keep saying estimating time remaining?

There are various reasons why your iPhone will stuck on "Estimating Time Remaining". In most cases, it is caused by the several situations below: The server is busy and result in the time delay, because too many users are updating iOS over a period of time. It is suggested to try again later.

How do I fix estimating time remaining on iOS 13?

Restart your device. You may want to troubleshoot slow Wi-Fi issues. Reset network settings by going to Settings > General > Reset > Reset Network Settings. (note that this will remove your network settings such as your Wi-Fi passwords etc).

Why does iPhone 13 take so long to set up?

Setting up an iPhone should just take a few minutes if you are not restoring any backups to your iPhone. If you are restoring an iTunes or iCloud backup, the setup procedure may take a little longer because the files must be retrieved from your computer or iCloud and then restored on your device.

Why is my iPad stuck on update requested?

When the update requested is displayed on your iPhone/iPad, it means that your device is connecting to the Apple server to download iOS update files.


1 Answers

Your expression is interpreted as

( (int)(elapsed.TotalSeconds / ItemPos) ) * (Count - ItemPos);

You have to delay the type-cast, all you need is an extra pair of ():

 //int seconds = (int)   (elapsed.TotalSeconds / ItemPos) * (Count - ItemPos)  ;
   int seconds = (int) ( (elapsed.TotalSeconds / ItemPos) * (Count - ItemPos) );
like image 138
Henk Holterman Avatar answered Oct 19 '22 23:10

Henk Holterman