2

In C#: How do I access GUI-Elements, like buttons or labels in another thread?

Luke
  • 5,431
  • 11
  • 52
  • 76

2 Answers2

5

Use Invoke, like this:

Invoke((MethodInvoker)(()=>lblName.Text="Meep"));
Blindy
  • 60,429
  • 9
  • 84
  • 123
4

You can't.

Instead, you need to call Invoke or BeginInvoke to execute code on the UI thread.

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933