×
Namespaces

Variants
Actions

Talk:Implement timers in Windows Phone

From Nokia Developer Wiki
Jump to: navigation, search

Contents

Atom217 - alternatively

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; using System.Windows.Threading;

namespace Timer {

   public partial class MainPage : PhoneApplicationPage
   {
       DispatcherTimer timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(.1)};
       // Constructor
       public MainPage()
       {
           InitializeComponent();
           this.timer.Tick+=new EventHandler(timer_Tick);
           this.Loaded += new RoutedEventHandler(timer_Tick);
       }
       private void timer_Tick(object sender, EventArgs e)
       {
           output.Text = DateTime.Now.ToLongTimeString();
       }
        
   }

}



MainPagexaml .cs

output is the name of the textblock

atom217 00:56, 25 March 2012 (EET)

Hamishwillee - Why this timer

Windows Phone has a number of different timers. It would be useful to explain why you're using this one, and its relative benefits/downsides when compared to other ones.

Hamishwillee - Thanks for the fixes

Thanks for the tidy up Matthew (and Chintan). Definitely an improvement.

hamishwillee 06:57, 11 February 2013 (EET)

Jweide - good example

Thank you, this was just what I needed.

Jokke

jweide 15:24, 6 April 2013 (EEST)

 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×