public void refreshLabelWatch_null() { //InvokeRequired判断该函数现在是否是主线程在调用,如果是其他线程则返回true if (label_watch.InvokeRequired) { //如若label不能操作了,则返回,防止异常 if (label_watch.Disposing || label_watch.IsDisposed) { return; } //把自己绑定 nullThread = refreshLabelWatch_null; Invoke(this.nullThread, new object[] { }); } else { label_watch.Text = ""; } }
public void picEnable() { //InvokeRequired判断该函数现在是否是主线程在调用,如果是其他线程则返回true if (pictureBox1.InvokeRequired || pictureBox2.InvokeRequired || pictureBox3.InvokeRequired || pictureBox4.InvokeRequired) { //如若label不能操作了,则返回,防止异常 if ((pictureBox1.Disposing || pictureBox1.IsDisposed) || (pictureBox2.Disposing || pictureBox2.IsDisposed) || (pictureBox3.Disposing || pictureBox3.IsDisposed) || (pictureBox4.Disposing || pictureBox4.IsDisposed)) { return; } //把自己绑定 enableThread = picEnable; Invoke(this.enableThread, new object[] { }); } else { pictureBox1.Enabled = !pictureBox1.Enabled; pictureBox2.Enabled = !pictureBox2.Enabled; pictureBox3.Enabled = !pictureBox3.Enabled; pictureBox4.Enabled = !pictureBox4.Enabled; } }