title: C# Threading - an array of threads, where each thread contains a form with an image
body: <p>I have an array of five threads. Each thread contains the same form, each form is put on to the screen in a different location (still working on that method :P).</p>
  
  <p>I am trying to have each form load its contents (an image) before the other forms have finishing being placed. At the moment this works for the first form, but the others are blank or disappear :P</p>
  
  <p>Originally each form would be placed but the method would need to finish before all the forms contents were displayed.</p>
  
  <p>Any help would be appreciated, thanks :)</p>
  
  <pre><code>public partial class TrollFrm : Form
  {
      int number = 0;
  
      public TrollFrm()
      {
          InitializeComponent();
  
          startThreads();
  
      }
  
      private void TrollFrm_Load(object sender, EventArgs e)
      {
  
      }
  
      private void TrollFrm_FormClosing(object sender, FormClosingEventArgs e)
      {
          e.Cancel = true;
      }
  
      public void startThreads()
      {
          Thread[] ThreadArray = new Thread[5];
  
          for (int i = 0; i &lt; 5; i++)
          {
              ThreadArray[i] = new Thread(new ThreadStart(createForm));
  
              ThreadArray[i].Start();
          }
      }
  
      public void createForm()
      {
          Form frm = new TrollChildFrm();
  
          Random randomX = new Random();
  
          Random randomY = new Random();
  
          number++;
  
          int xValue;
  
          int yValue;
  
          if (number % 2 == 0)    //number is even.
          {
              xValue = (Convert.ToInt32(randomX.Next(1, 1920))) + 200;
  
              yValue = (Convert.ToInt32(randomY.Next(1, 1080))) - 200;
          }
  
          else    //number is not even.
          {
              xValue = (Convert.ToInt32(randomX.Next(1, 1920))) - 200;
  
              yValue = (Convert.ToInt32(randomY.Next(1, 1080))) + 200;
          }
  
          frm.Show();
  
          frm.Location = new Point(xValue, yValue);
  
          Thread.Sleep(1000);
      }
  </code></pre>