Reputation: 874
Is it possible to implement a stopwatch showing stopwatch values changing on label as watch is running.
I have added stopwatch using following code
Stopwatch stopwatch = new Stopwatch();
// Begin timing
stopwatch.Start();
// Stop timing
stopwatch.Stop();
How should i show time running on a label ????
Upvotes: 0
Views: 1660
Reputation: 89117
Use a Timer instead of a 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
}
Upvotes: 2