DateTime MainTimer_last_Tick = DateTime.Now;
System.Windows.Forms.Timer timer_Calc_Remaining;
timer_Calc_Remaining.Enabled = true;
timer_Calc_Remaining.Interval = 100;
timer_Calc_Remaining.Tick += new System.EventHandler(this.timer_Calc_Remaining_Tick);
at the start of the main timer or tick:
timer_Main.Enabled = true;
MainTimer_last_Tick = DateTime.Now;
private void timer_Calc_Remaining_Tick(object sender, EventArgs e)
{
int remaining_Milliseconds = (int)(MainTimer_last_Tick.AddMilliseconds(timer_Main.Interval).Subtract(DateTime.Now).TotalMilliseconds);
...
}
Tarek source
share