private void AppendLabel2Text(string text, int channel) { try { // 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. switch (channel) { case 0: if (this.Motor1_Label2.InvokeRequired) { AppendLabel2TextCallback d = new AppendLabel2TextCallback(AppendLabel2Text); this.Invoke(d, new object[] { text, channel }); } else { this.Motor1_Label2.Text = text; } break; case 1: if (this.Motor2_Label2.InvokeRequired) { AppendLabel2TextCallback d = new AppendLabel2TextCallback(AppendLabel2Text); this.Invoke(d, new object[] { text, channel }); } else { this.Motor2_Label2.Text = text; } break; } } catch { } }
private void AppendLabel2Text(string text) { try { // 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.label2.InvokeRequired) { AppendLabel2TextCallback d = new AppendLabel2TextCallback(AppendLabel2Text); this.Invoke(d, new object[] { text }); } else { this.label2.Text = text; } } catch{} }