G
Goodman Ngwenya
Guest
Timer Code on page load:
DateTime endTime = new DateTime(2019, 08, 28, 14, 00, 0);
public void StartCountDownTimer()
{
try
{
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += t_Tick;
TimeSpan ts = endTime - DateTime.Now;
lblCountDown.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
timer.Start();
}
catch (Exception ex)
{
string Error = ex.Message;
}
}
System.Timers.Timer timer;
void t_Tick(object sender, EventArgs e)
{
TimeSpan ts = endTime - DateTime.Now;
string NewTimer = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
//txtCountDown.Text = NewTimer;
lblCountDown.Text = NewTimer;
if ((ts.TotalMilliseconds < 0) || (ts.TotalMilliseconds < 1000))
{
timer.Stop();
lblCountDown.Text = "The day has arrived";
}
}
Navigate Code using a button click on the same page:
private void ClickAboutTab(object sender, EventArgs e){await Navigation.PushAsync(new Page());}
Continue reading...
DateTime endTime = new DateTime(2019, 08, 28, 14, 00, 0);
public void StartCountDownTimer()
{
try
{
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += t_Tick;
TimeSpan ts = endTime - DateTime.Now;
lblCountDown.Text = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
timer.Start();
}
catch (Exception ex)
{
string Error = ex.Message;
}
}
System.Timers.Timer timer;
void t_Tick(object sender, EventArgs e)
{
TimeSpan ts = endTime - DateTime.Now;
string NewTimer = ts.ToString("d' Days 'h' Hours 'm' Minutes 's' Seconds'");
//txtCountDown.Text = NewTimer;
lblCountDown.Text = NewTimer;
if ((ts.TotalMilliseconds < 0) || (ts.TotalMilliseconds < 1000))
{
timer.Stop();
lblCountDown.Text = "The day has arrived";
}
}
Navigate Code using a button click on the same page:
private void ClickAboutTab(object sender, EventArgs e){await Navigation.PushAsync(new Page());}
Continue reading...