title: How to stop timer affacted by button click?
body: <p>i am working on a winform application in which i have a timer.it is being used for showing stopwatch on the form. When i fire a button than my timer is interrupted. i want my timer to be uninterrupted while button is clicked. My code is as followed:-</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      if (!_timerRunning)
      {
          // Set the start time to Now
          _startTime = DateTime.Now;
  
          // Store the total elapsed time so far
          _totalElapsedTime = _currentElapsedTime;
  
          _timer.Start();
          _timerRunning = true;
      }
      SqlConnection Con = new SqlConnection("Data Source=69.162.83.242,1232;Initial Catalog=test1;Uid=test;pwd=1234@Test;MultipleActiveResultSets=true;Connect TimeOut=60000;");
      //SqlConnection Con = new SqlConnection("Data Source=ADMIN-PC\\YASH;Initial Catalog=test;Integrated Security=True; Connect TimeOut=600");
      Con.Open();
      string messageMask = "{0} @ {1} : {2}";
      string message = string.Format(messageMask, label6.Text, DateTime.Now.ToShortTimeString(), richTextBox2.Text);
      richTextBox1.AppendText(Environment.NewLine + message);
      SqlCommand cmd, cmd1;
      cmd = new SqlCommand("Update Chat set UserInitial=@message,Updated=1 where ExpertName ='" + label6.Text + "'", Con);
      cmd.Parameters.AddWithValue("@message", message);
      cmd.ExecuteNonQuery();
      Con.Close();
      richTextBox2.Text = String.Empty;
      richTextBox1.ScrollToCaret();
  }
  
  private void timer1_Tick(object sender, EventArgs e)
  {
      richTextBox1.ScrollToCaret();
      count = count + 1;
      count1 = count1 + 1;
      timerSinceStartTime = new TimeSpan(timerSinceStartTime.Hours, timerSinceStartTime.Minutes, timerSinceStartTime.Seconds + 1);
      // The current elapsed time is the time since the start button was
      // clicked, plus the total time elapsed since the last reset
      _currentElapsedTime = timerSinceStartTime + _totalElapsedTime;
  
      // These are just two Label controls which display the current 
      // elapsed time and total elapsed time
  
      if (count1 == 180)
      {
          MessageBox.Show("You are Automaticlly hired by User");
          if (label7.Visible == true)
          {
              label7.Visible = false;
              count = 0;
              timerSinceStartTime = new TimeSpan(00, 00, 00);
              label3.Visible = true;
          }
      }
      label3.Text = timerSinceStartTime.ToString();
  
  
      // If we're running on the UI thread, we'll get here, and can safely update 
      // the label's text.
  
  
      richTextBox1.ScrollToCaret();
  }
  </code></pre>
  
  <p>how to solve it??
  thanks in Advance</p>