//Appen label text function private void AppendLabel1Text(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_Label1.InvokeRequired) { AppendLabel1TextCallback d = new AppendLabel1TextCallback(AppendLabel1Text); this.Invoke(d, new object[] { text }); } else { this.Motor1_Label1.Text = text; } break; case 1: if (this.Motor2_Label1.InvokeRequired) { AppendLabel1TextCallback d = new AppendLabel1TextCallback(AppendLabel1Text); this.Invoke(d, new object[] { text }); } else { this.Motor2_Label1.Text = text; } break; } } catch { } }
private void AppendLabel1Text(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.label1.InvokeRequired) { AppendLabel1TextCallback d = new AppendLabel1TextCallback(AppendLabel1Text); this.Invoke(d, new object[] { text }); } else { this.label1.Text = text; } } catch{} }