In this short video I show you how to create a Silverlight Timer using the DispatcherTimer class. I then show you a real world example where you would use a timer in Silverlight.
Project Download: http://tw0.us/4mr
Nice tutorial. Two things came to mind while watching it.
When the little bar suggesting a using is needed comes up, you showed the two ways to resolve it, but there is another, quicker way I use all the time.The Ctrl+. (Ctrl + period) shortcut opens the context menu and hitting enter then accepts the first entry, which is usually the one you want.
When initialising a timespan, I used the “new TimeSpan(h, m, s)” syntax for ages myself, until I discovered that the TimeSpan has some nice static methods for initialising timespans. So instead of “dt.Interval = new TimeSpan(0, 0, 4);” you could have used “dt = TimeSpan.FromSeconds(4);”, which I think makes the code just that little bit more readable.
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.