I'm not familiar with Multi-threading programming , i only know a few about the basics. i want to set a value for example a label text from another thread to main thread(i even don't know that i'm right about main thread but you'll what i want to do when you saw the code) I need a solution to work for others controls and controls's values too(like location of a button)
static int s = 0;
void v()
{
for (int i = 0; i > -1; i++)
{
s++;
label1.Text = s.ToString();
}
}
private void buttonX1_Click(object sender, EventArgs e){
ThreadStart ts = new ThreadStart(v);
Thread trd = new Thread(ts);
trd.Start();
}
thats my whole code and i have only one label
and one button
when i click on button
i get this error:
Cross-thread operation not valid: Control 'label1' accessed from a thread other than the thread it was created on.
any help will be appreciated.