title: Timer to show seconds, minutes and hours in iOS Xamarin
body: <p>I am working on iOS Application in Xamarin.</p>
  
  <pre><code>timer1 = new System.Timers.Timer();
  timer1.Interval = 1000;
  
  //Play.TouchUpInside += (sender,e)=&gt;
  //{
         timer1.Enabled = true;
         Console.WriteLine("timer started");
         timer1.Elapsed += new ElapsedEventHandler(OnTimeEvent);
  //}
  </code></pre>
  
  <p>This is what i have written in viewdidload();</p>
  
  <pre><code>public void OnTimeEvent(object source, ElapsedEventArgs e)
  {
      count++;
      Console.WriteLine("timer tick");
      if (count == 30)
      {
          timer1.Enabled = false;
          Console.WriteLine("timer finished");
  
          new System.Threading.Thread(new System.Threading.ThreadStart(() =&gt;
          {
              InvokeOnMainThread(() =&gt;
              {
                  StartTimer.Text = Convert.ToString(e.SignalTime.TimeOfDay); // this works!
              });
          })).Start();
      }
  
      else
      {
          //adjust the UI
          new System.Threading.Thread(new System.Threading.ThreadStart(() =&gt;
          {
              InvokeOnMainThread(() =&gt;
              {
                  StartTimer.Text = Convert.ToString(e.SignalTime.TimeOfDay); // this works!
              });
          })).Start();
  
          timer1.Enabled = false;
          Console.WriteLine("timer stopped");
      }
  }
  </code></pre>
  
  <p>This is the event I have called when I clicked on button play. I want this method to keep running so that time get updated on the label (<code>starttimer.Text</code>) in the UI. Like Runnable Interface we use in Android, what do we have to use in iOS to keep it running?</p>