D L

D L

  • NA
  • 11
  • 17.4k

Cross thread Exception

Jan 7 2013 9:25 AM
I don't understand why I get a cross threading exception on this. Can someone plz explain?



Thread1 = new Thread(()=>UpdateLabel(ref label1));
Thread1.Start();



void UpdateLabel(ref Label _label1)
{
lock(_label1)
{
_label1.Text = "Hello World";
}
}



I thought that would make it a resource shared between the GUI thread and Thread1. 

Answers (2)