Quantcast
Channel: Using timers and DateTime.Now
Viewing all articles
Browse latest Browse all 12

Using timers and DateTime.Now

$
0
0
Ok thanks. How do I do that?
After the call to the DispatcherTimer constructor, start typing this: timer.Tick +=
Visual Studio should prompt you about pressing TAB for auto-generating a Tick handler. Press tab twice to have Visual Studio create the handler. You should end up with this:

        public MainPage()  
        {  
            InitializeComponent();  
 
            DispatcherTimer timer = new DispatcherTimer();  
            timer.Tick += new EventHandler(timer_Tick);  
            timer.Interval = new TimeSpan(0, 0, 1);  
            timer.Start();  
        }  
 
        void timer_Tick(object sender, EventArgs e)  
        {  
            throw new NotImplementedException();  
        } 

Replace the throw statement with the code you want to run.


Richard Woo

Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>