title: Running own class on separate thread
body: <p>I want to run an own class in another thread, but if I do that I can't use my, for example, labels inside of an <code>EventHandler</code>, how can I avoid that?</p>
  
  <p>That's how my code looks:</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.Threading;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace Ts3_Movearound
  {
      public partial class Form1 : Form
      {
          TS3_Connector conn = new TS3_Connector();
          Thread workerThread = null;
          public Form1()
          {
              InitializeComponent();
              conn.runningHandle += new EventHandler(started);
              conn.stoppedHandle += new EventHandler(stopped);
          }
  
          private void button1_Click(object sender, EventArgs e)
          {
              //System.Threading.Thread connw = new System.Threading.Thread(conn);
              workerThread = new Thread(conn.Main);
              workerThread.Start();
          }
  
          public void started(Object sender, EventArgs e)
          {
              label1.Text = "Status: Running!";
          }
          public void stopped(Object sender, EventArgs e)
          {
              label1.Text = "Status: Stopped!";
          }
      }
  }
  </code></pre>
  
  <p>And that's the error:</p>
  
  <blockquote>
    <p><em>InvalidOperationExpetion in Line "label1.Text = "Status: Running!";"</em></p>
  </blockquote>