title: how to make a loop delay windows form c#
body: <p>I'm trying to make an auto clicker that repeatedly clicks with a delayed interval between each click. I am using visual studio windows form app in c#.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private void ClickButton_Click(object sender, EventArgs e)
  {
      bool click = true;
  
       while (click == true) {
          System.Threading.Thread.Sleep(1000);
          ClickButton.PerformClick();
      }
  }
  </code></pre>
  
  <p>The program seems to really hate the while loop. The program crashes every time I press the button.</p>