是否可以实现一个秒表,当手表运行时,在标签上显示秒表数值的变化。
我使用以下代码添加了秒表
Stopwatch stopwatch = new Stopwatch();
// Begin timing
stopwatch.Start();
// Stop timing
stopwatch.Stop();我应该如何在标签上显示时间运行?
发布于 2013-03-30 05:17:33
使用Timer而不是Stopwatch。
// create a timer that fires every 10 ms
Timer aTimer = new Timer(10);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Enabled = true;
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
// update your label here
}https://stackoverflow.com/questions/15711214
复制相似问题