title: building smooth animation in C#
body: <p>First here's the code.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  
  namespace winform_project
  {
    public partial class Form1 : Form
    {
      void movement_correct(PictureBox pic, int i)
      {
          System.Threading.Thread.Sleep(25);
          pic.Top += (i - 1);
          pic.Left += (i + 3);
      }
  
      void movement_up(PictureBox pic, int i)
      {
          System.Threading.Thread.Sleep(25);
          pic.Top -= (i - 1);
          pic.Left -= (i + 3);
      }
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          for (int i = 0; i &lt; 5; i++)
          {
              movement_correct(pictureBox1, i);
              movement_correct(pictureBox2, i);
              movement_correct(pictureBox3, i);
              movement_correct(pictureBox4, i);
              movement_correct(pictureBox5, i);
              movement_correct(pictureBox6, i);
              movement_correct(pictureBox7, i);
              movement_correct(pictureBox8, i);
              movement_correct(pictureBox9, i);
              movement_correct(pictureBox10, i);
          }
  
          for (int i = 0; i &lt; 5; i++)
          {
              movement_up(pictureBox1, i);
              movement_up(pictureBox2, i);
              movement_up(pictureBox3, i);
              movement_up(pictureBox4, i);
              movement_up(pictureBox5, i);
              movement_up(pictureBox6, i);
              movement_up(pictureBox7, i);
              movement_up(pictureBox8, i);
              movement_up(pictureBox9, i);
              movement_up(pictureBox10, i);
          }
  
      }
   }
  }
  </code></pre>
  
  <p>There are 10 dummy picture boxes. Whenever i click the button they start to move a bit(sort of like the enemies in space invaders).</p>
  
  <p>I am trying to make a smooth animation in winforms. The problem is that the animation in not as smooth as i want it to be. In my code all the boxes aren't moving simultaneously, there is a little bit of noticeable gap in their movement. What i want is smooth movement.</p>
  
  <p>I was thinking of multi threading it but then realized it would mean one thead for each objects. Is there any other way(Within winforms).</p>
  
  <p>Thanks for the help.</p>