In a c# windows application i have 2 forms namely form1 and form2 in the form one if i click a button it will show the form 2 with a label. I want to pass a value from form1 to form2 label control. But i get cross thread violation error. I searched the net but i all the discussions are about communication between UI Thread and Backgroundworker Thread. How i can communicate between this Two UI Threads?
private void btnStart_Click(object sender, EventArgs e)
form2 mform = new form2();
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(mform.Show));
for (int i = 0; i < 100; i++)
mform.label1.Text = i.ToString(); // <----- Cross Thread Violation Here