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

Using timers and DateTime.Now

$
0
0
Whenever I type in "DispatcherTimer" I get an error.
You're probably missing a 'using' statement. Here's a tip: if DispatcherTimer is underlined after you type it, right-click on it. If "Resolve" is in the popup menu, then it is a reference problem that Visual Studio knows how to fix. Select it and choose either a using statement or fully qualified path that fixes it.


Richard Woo


That did the trick, thanks!

Here's what I've got now, the timer isn't working though, anything I've missed out?

        public MainPage()
        {
            InitializeComponent();
            
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Start();

        }

        private void timer_Tick()
        {
            textBlock1.Text = DateTime.Now.ToString("t");
            textBlock2.Text = DateTime.Now.ToString("D");
        }

Viewing all articles
Browse latest Browse all 12

Trending Articles



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