简体   繁体   English

如何在C#中显示计时器的刻度

[英]How to display the tick of the timer in C#

I want to know how can I achieve this goal? 我想知道如何实现这一目标?

    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();
}

I want to happen is that when I press the button the timer will run and display the time in label1.text and it will stop until it will reach the timer stop function 我想要发生的是,当我按下按钮时,计时器将运行并在label1.text中显示时间,它将停止,直到它到达定时器停止功能

var sw = Stopwatch.StartNew();
//100 lines of code... 
label1.Text = sw.Elapsed.ToString();

??? ???

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM