keydown - C# Stopwatch on-the-fly update -


(my first question here!) hi, kind of beginner in c#. tried build simple timer (in windows.forms). made label indicates time, , used stopwatch class (from system.diagnostics). trigger event starting / stopping stopwatch spacebar keydown event. after second tap stopwatch stops , label.text assigned stopwatch.elapsed value. want continuously update label, don't know how. if make while(stopwatchname.isrunning) in event itself, event indefinitely continue , won't respond second tap.

thanks in advance ideas!

you should have timer fires (e.g. every 10ms) - start timer when start stopwatch, , stop timer when stop stopwatch. timer tick event set label's text property stopwatch.

the timer's interval won't exact of course - that's okay, because point rely on stopwatch actual timing. timer there update label frequently.


Comments