title: How to slow down a while loop inside a timer
body: <p>I need some help slowing down a while loop inside a timer. I'm making a platform game and want a picturebox (block) to move back and forth, which i have succeeded with. However, the block is moving so fast that it is making everthing else lag. Any help would be appreciated!</p>
  
  <pre><code>        private void timer2_Tick(object sender, EventArgs e)
      {
  
          while (block.Left &gt; (ClientSize.Width-ClientSize.Width))
          {
  
              block.Left -= 1;
              if (block.Left == (ClientSize.Width - ClientSize.Width))
              {
                  break;
              }
  
          }
          while (block.Right &lt; ClientSize.Width)
          {
  
              block.Left += 1;
              if (block.Right == ClientSize.Width)
              {
                  break;
              }  
          }   
      }
  }
  </code></pre>