11
Answers

Raising and subscribing to events

kyle

kyle

15y
5.1k
1
I need help with the syntax to update the BackColor of a label on a form while a while loop is running on another form.

Form1 has a label.

Form2 has an if statement inside a while loop. When the if statement evaluates as true I need to change the BackColor of a label on Form1.

Thanks in advance for your help.

Class MyClass
{
     
public delegate void ChangeColorDelegate();
     
public event ChangeColorDelegate ChangeColor;
 
     
While(true)
 
       
if (something == true)
           
(HAVING TROUBLE HERE)
           
if (ChangeColor != null)
               
ChangeColor();
 
}
 
Class MyOtherClass
{
     
MyClass test = new MyClass();
      test
.ChangeColor += (THIS IS WHERE I AM HAVING DIFFICULTY)

Answers (11)