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?
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.
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).
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.
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.
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) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With