public void ClearControls() { if (InvokeRequired) { var d = new NoArgReturningVoidDelegate(ClearControls); Invoke(d, null); } else { Controls.Clear(); } }
public void ConnectionMade() { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.textBox2.InvokeRequired) { NoArgReturningVoidDelegate d = new NoArgReturningVoidDelegate(ConnectionMade); this.Invoke(d, new object[] { }); } else { this.connectionLabel.Text = "Connection Made"; this.connectionLabel.ForeColor = Color.Black; } }