title: Stop running the code after 15 seconds
body: <p>I'm trying to write something to stop running the code after 15 seconds of running.</p>
  
  <p>I don't want <code>While</code> loop or any kind of loop to be used and would like to use IF-ELSE conditions instead as it would make it easier for me in my code.</p>
  
  <p>The part of code I want to stop being executed after 15 seconds is a FOR loop itself. Let's consider the below code for example:</p>
  
  <pre><code>for (int i = 1; i &lt; 100000; i++)
  {
      Console.WriteLine("This is test no. "+ i+ "\n");
  }
  </code></pre>
  
  <p>How would you stop this loop after 15 seconds of running?</p>