title: C# Winforms timers / object reference not set to an instance of an object
body: <p>I have this code:</p>
  
  <pre><code>System.Timers.Timer ti1, ti2, ti3;
  
  private void button1_Click(object sender, EventArgs e)
  {
     if(_1 == true)
  {
      ti1 = new System.Timers.Timer(1000);
      ti1.Interval = 1000;
      ti1.Elapsed += new System.Timers.ElapsedEventHandler(tiel1);
      ti1.Enabled = true;
  }
  else
  {
      ti1.Stop();
  }
  }
  </code></pre>
  
  <p>It successfully works, but because I do not want to use the same code, I created a helper method:</p>
  
  <pre><code>private void my_timer(System.Timers.Timer tim, System.Timers.ElapsedEventHandler Tick)
          {
              tim = new System.Timers.Timer(1000);
              tim.Interval = 1000;
              tim.Elapsed += new System.Timers.ElapsedEventHandler(Tick);
              tim.Enabled = true;
          }
  </code></pre>
  
  <p>and then I call it <code>my_timer(ti1, tiel1)</code></p>
  
  <p>but when <code>ti1.Stop()</code> is called it gives me this error "object reference not set to an instance of an object".</p>
  
  <p>Any idea why?
  Thanks.</p>