title: C# simple stopwatch - Total beginner
body: <p>I come from embedded C programming and I don't absolutely know anything about oop, task, threads, ecc..
  I'm figuring out the basics concepts of C# and oop and wanted to try coding a simple stopwatch.</p>
  
  <p>Goal: Toggle the stopwatch state with a button and show the value inside the button itself.</p>
  
  <p>So far I've come to this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace Cronometro
  {
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
          }
      }
  
      public class MyTimerClass
      {
          private DateTime TimeValue;
          private System.Timers.Timer TimerObj;
          private const int TimeInterval = 1;
  
          public MyTimerClass()
          {
              TimeValue new DateTime(0, 0, 0, 0, 0, 0, 0, DateTimeKind.Local);
              TimerObj = new System.Timers.Timer(TimeInterval);
              TimerObj.AutoReset = true;
  
              TimerObj.Elapsed += TimerObj_Elapsed;
          }
  
          private void TimerObj_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
          {
              TimeValue = TimeValue.AddMilliseconds((double)TimeInterval);
          }
  
          public void Start()
          {
              TimerObj.Start();
          }
          public void Stop()
          {
              TimerObj.Stop();
          }
      }
  }
  </code></pre>
  
  <p>Come to this point, I just wanted to print the value with Button.Content but seems like I cannot use it outside of the <code>MainWindow</code> class.</p>
  
  <p>What should I do? I started thinking about creating a task inside the main class and wait for the timer event to print the value but I know nothing about threads and tasks.</p>