How can I capture the label value of my chronometer
I'm doing a chronometer in C# and I know how to stop the timer but the thing that I really need is to stop only the label value and let the timer running.
The only thing that I found is to make my label this way:
myLabel.Visible = False;
timer1.Stop();
But I don't want to make it invisible or Stop the timer, I just want to capture the timer valu开发者_StackOverflow中文版e in the label and let the timer running.
If you want to know how long something takes, use the stopwatch class, timers are used for their onelapsed events. To the the amount of time on a stopwatch use:
Stopwatch sw = new Stopwatch();
long timepassed = sw.ElapsedMilliseconds;
Assuming you've an event on the timer that triggers every x seconds and updates the label, you just need to add some logic to this event to prevent the label from being updated if "you don't want it to be". You can leave the timer running.
精彩评论