Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have implemented a timer using dispatcher timer class

I know how to start and stop the timer, but I don't know how to pause and resume it. Any help would be greatly appreciated. Thanks.

This is how i usually start and stop the timer.

private DispatcherTimer T;


C#
public void timer_Start(double gap)
       {
           T.Interval = TimeSpan.FromSeconds(gap);
           T.Tick += show_time();
           T.Start();
       }



C#
private void button2_Click(object sender, RoutedEventArgs e)
     {
         T.Stop();
     }
Posted

This kind of timer fires a Tick call every Interval unit of time.

For Pause/Resume functionality you have to build that into your Tick handler, start and stop the timer.
 
Share this answer
 
Use Stop for Pause, and Start for Resume.

But remember it does not allow to pause in intermediate state.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900