Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Estimated Time of Completion Calculation - C#

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: Sun, Mar 18, 2012, 1:01 PM


private DateTime _startTime;
private int _imax; // upper bound of the zero-based array being processed

private void UpdateStatus(int i)
{
    var qtyDone = i + 1;
    var qtyTotal = _imax + 1;
    var msElapsed = DateTime.Now.Subtract(_startTime).TotalMilliseconds;
    var unitTime = msElapsed / (double)qtyDone;
    var etc = DateTime.Now.AddMilliseconds(unitTime * qtyTotal);

    uxProcessingLabel.Text = qtyDone.ToString("#,##0") + " of " + qtyTotal.ToString("#,##0");
    uxEtcLabel.Text = etc.ToString("MM/dd/yy h:mm:ss tt");
    uxProcessingLabel.Refresh();
    uxEtcLabel.Refresh();
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.