title: Running a loop for specific time using timer in windows form application C#
body: <p>I'm trying to make some calculations repeatedly for a specific amount of time (the <code>time</code> is variable and provided by the user.) </p>
  
  <p>I tried using timer available in windows form application toolbox in visual studio, but there seems to be a problem. The program gets stuck when I start the timer and associate the variable for <code>time</code> with the while loop; the <code>time</code> variable is being decremented in each tick event of timer and I need to run the while loop as long as time is greater than 0.</p>
  
  <pre><code>private void timer1_Tick(object sender, EventArgs e)
      {
          if (time == 0)
              timer1.Stop();
  
          else
          {
              time--;
              textBoxTime.Text = time.ToString();
          }
  
      }
  </code></pre>
  
  <p>and here is the while loop that blocks the program</p>
  
  <pre><code>while (time&gt;0)
  {
     computations();
  }
  </code></pre>