title: Multithreading in C# - Update Labels
body: <p>So I have 3 labels and have to update all three of them at the same time using a random number until the user clicks a button that stops it.</p>
  
  <p>This is what I have on my start button</p>
  
  <pre><code>private void start_Click(object sender, EventArgs e)
  {
          t1 = new Thread(new ThreadStart(FirstNumber));
          t2 = new Thread(new ThreadStart(SecondNumber));
          t3 = new Thread(new ThreadStart(ThirdNumber));
  
          t1.Start();
          t2.Start();
          t3.Start();
  }
  </code></pre>
  
  <p>This is what the methods that generate the random numbers look like</p>
  
  <pre><code>public void FirstNumber()
  {
          int j = r.Next(0, 50);
          int k = r.Next(50, 100);
          for (int i = j; i &lt;= k; i++)
          {
              number1.Text = i.ToString();
              Thread.Sleep(200);
          }
  }
  </code></pre>
  
  <p>When I debug I get the following error:</p>
  
  <blockquote>
    <p>Cross-thread operation not valid: Control 'number2' accessed from a thread other than the thread it was created on.</p>
  </blockquote>
  
  <p>I don't understand how I am meant to create controls for each thread, so any help is appreciated. </p>
  
  <p>One more thing, will the user be able to click the stop button while the labels are being updated? Or do I need to add another thread that waits for the user input?</p>
  
  <p>Thanks a lot!</p>