// Make Thread-Safe Calls to Windows Forms Controls public void SetErrorCount(string text) { // 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.lblErrorCount.InvokeRequired) { SetErrorCallback d = new SetErrorCallback(SetErrorCount); this.Invoke(d, new object[] { text }); } else { this.lblErrorCount.Text = text; } }
private void error(string title, string message) { if (labPrecision.InvokeRequired) { SetErrorCallback d = new SetErrorCallback(error); Invoke(d, new object[] { title, message }); } else { MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); groupBox2.Enabled = true; groupBox3.Enabled = true; picLoader.Hide(); labLoader.Hide(); } }
public void SetErrorLabel(string label) { // 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 (((System.Windows.Forms.Label)this.sensorLabels["ErrorLabel"]).InvokeRequired) { SetErrorCallback d = new SetErrorCallback(SetErrorLabel); this.Invoke(d, new object[] { label}); } else { ((System.Windows.Forms.Label)this.sensorLabels["ErrorLabel"]).Text = label; ((System.Windows.Forms.Label)this.sensorLabels["ErrorLabel"]).Refresh(); } }