title: C# Cross-thread operation not valid
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1353857/cross-thread-operation-not-valid-control-accessed-from-a-thread-other-than-the-t">Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.</a>  </p>
  </blockquote>
  
  
  
  <p>I get an error message - can anyone give me some pointers.</p>
  
  <blockquote>
    <p>Cross-thread operation not valid: Control 'pbx_1' accessed from a
    thread other than the thread it was created on.</p>
  </blockquote>
  
  <p>I have had a look on here but i cant seem to get it to work.  I am quite new to c# so I am probably missing something.</p>
  
  <pre><code> Console.WriteLine("backgroundWorker1");
   while (!backgroundWorker1.CancellationPending) {
       Thread.Sleep(100);
       if (pbx_1.Location.X &lt; Click_X) {
           pbx_1.Location = new Point(20, pbx_1.Location.X + MoveAmt);
       }
  
       if (pbx_1.Location.X &gt; Click_X) {
           pbx_1.Location = new Point(20, pbx_1.Location.X - MoveAmt);
       }
  
       backgroundWorker1.ReportProgress(1);
   }
  </code></pre>