Home ยป Silverlight

Timers in Silverlight

26 Nov 2008 9:40 AM 0 Comments Bookmark and Share kick it on DotNetKicks.com

Before Silverlight 2 one had to go through loops to implement a timer, resulting in many different hacks.

Now no more.  Simple.  Elegant.  Logical.  Common sense.

   1: System.Windows.Threading.DispatcherTimer t = new DispatcherTimer();
   2:            t.Interval = new TimeSpan(0, 1, 0);
   3:            t.Tick += new EventHandler(MyMethod);
   4:            t.Start();
   5:  
   6:  
   7: private void MyMethod()
   8: {
   9:     // Do something
  10: }

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Comments are closed