Estimate seconds left (based on time & progress)
<p>I'm trying to estimate how many seconds is left of an MSI installation. Though I know this will not be accurate, my calculation seems more off than it should be - how can I improve? One problem is that often I find that the progress rockets from ~0% to ~95% which for a very long time evaluates to 0 seconds left.</p>

<p>I get the progress event from the MSIs, and each time progress is updated I do the following:</p>

<pre><code>    private int CalculateSecondsLeft(DateTime start, int overallProgress)
    {
        lock (this)
        {         
            if (overallProgress == 0)
            {
                return 0;
            }

            var timeSpent = DateTime.Now - start;
            double cal1 = timeSpent.TotalSeconds / overallProgress;
            double cal2 = cal1 * (100 - overallProgress);
            return (int)cal2;
        }
    }
</code></pre>
