1
我已經使用下面的代碼實現了向上計時器(或秒錶)。我想知道是否有一個高效和標準的方式來實現這個在Windows手機上使用C#。在Windows Phone應用程序中使用c計數定時器#
任何建議,將不勝感激。
private void start_click()
{
lhours = 0; lmins = 0; lsecs = 0; lmsecs = 0;
myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000); // 1000 Milliseconds
myDispatcherTimer.Tick += new EventHandler(Each_Tick);
myDispatcherTimer.Start();
}
public void Each_Tick(object o, EventArgs sender)
{
lsecs = lsecs + 1;
if (lsecs > 59)
{
lsecs = 0;
lmins = lmins + 1;
if (lmins > 59)
{
lmins = 0;
lhours = lhours + 1;
if (lhours > 23)
{
lhours = 0;
ldays = ldays + 1;
}
}
}
lblTimerDisplay.Text = ldays + ":" + lhours + ":" + lmins + ":" + lsecs + ":";
}
感謝您的幫助,但在何處以及如何調用此start_click()和Each_Tick()方法?任何建議都會很好,對WP8來說是新的 – Debhere