I have a code and when you click on start some controls must be disabled for the safety... :
Thread t = new Thread(() => MyMethod(text));
button1.Enabled = false;
textBox2.Enabled = false;
button2.Enabled = false;
t.Start();
This is not a problem.
My problem is where i should turn all of them On again, My mean is when the MyMethod
ends , i have to Invoke
all the controls i want to enable them.
MyMethod(string text){
.
.
.
button1.Invoke(new MethodInvoker(delegate{ button1.Enabled=true; }));
textBox2.Invoke(new MethodInvoker(delegate{textBox2.Enabled=true; }));
button2.Invoke(new MethodInvoker(delegate{ button2.Enabled=true; }));
}
So if we had a bunch of Controls Set, It would be hard to change the values of they in a thread.
Is there anyway to Access these for an easier or faster way ?
Thanks,