1
下面是我試圖用作我們正在構建的桌面任務計時器上的已用計時器的代碼。現在,當它運行時,它只會計數到60秒,然後重置並且不會添加到分鐘中。計時器在60秒後重置
//tick timer that checks to see how long the agent has been sitting in the misc timer status, reminds them after 5 mintues to ensure correct status is used
private void statusTime_Tick(object sender, EventArgs e)
{
counter++;
//The timespan will handle the push from the elapsed time in seconds to the label so we can update the user
//This shouldn't require a background worker since it's a fairly small app and nothing is resource heavy
var timespan = TimeSpan.FromSeconds(actualTimer.Elapsed.Seconds);
//convert the time in seconds to the format requested by the user
displaycounter.Text=("Elapsed Time in " + statusName+" "+ timespan.ToString(@"mm\:ss"));
//pull the thread into updating the UI
Application.DoEvents();
}
你能分享定時器初始化方式? –