我想知道如何实现这一目标?
private void btnProcess_Click(object sender, EventArgs e)
{
timer1.Start();
//100 plus line of code here
timer1.Stop();
}
int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
i++;
label1.text = i.toString();
}
我想要发生的是,当我按下按钮时,计时器将运行并在label1.text中显示时间,它将停止,直到它到达计时器停止功能
答案 0 :(得分:3)
var sw = Stopwatch.StartNew();
//100 lines of code...
label1.Text = sw.Elapsed.ToString();
???