private void SetBindKey2(INFO_LEVEL level) { if (this.pictureBox_BindKey2.InvokeRequired)//如果调用控件的线程和创建创建控件的线程不是同一个则为True { while (!this.pictureBox_BindKey2.IsHandleCreated) { //解决窗体关闭时出现“访问已释放句柄“的异常 if (this.pictureBox_BindKey2.Disposing || this.pictureBox_BindKey2.IsDisposed) { return; } } SetBindKey2Callback d = new SetBindKey2Callback(SetBindKey2); this.pictureBox_BindKey2.Invoke(d, new object[] { level }); } else { switch (level) { case INFO_LEVEL.INIT: this.pictureBox_BindKey2.Visible = false; break; case INFO_LEVEL.PASS: this.pictureBox_BindKey2.Visible = true; this.pictureBox_BindKey2.Image = global::RK7001Test.Properties.Resources.OK; break; case INFO_LEVEL.FAIL: this.pictureBox_BindKey2.Visible = true; this.pictureBox_BindKey2.Image = global::RK7001Test.Properties.Resources.Shape; break; case INFO_LEVEL.PROCESS: this.pictureBox_BindKey2.Visible = true; this.pictureBox_BindKey2.Image = global::RK7001Test.Properties.Resources.ic_loading; break; } } }
private void SetBindKey2(INFO_LEVEL level) { if (this.labelItemKey2.InvokeRequired)//如果调用控件的线程和创建创建控件的线程不是同一个则为True { while (!this.labelItemKey2.IsHandleCreated) { //解决窗体关闭时出现“访问已释放句柄“的异常 if (this.labelItemKey2.Disposing || this.labelItemKey2.IsDisposed) { return; } } SetBindKey2Callback d = new SetBindKey2Callback(SetBindKey2); this.labelItemKey2.Invoke(d, new object[] { level }); } else { switch (level) { case INFO_LEVEL.INIT: this.labelItemKey2.BackColor = Color.White; break; case INFO_LEVEL.PASS: this.labelItemKey2.BackColor = Color.Green; break; case INFO_LEVEL.FAIL: this.labelItemKey2.BackColor = Color.Red; break; case INFO_LEVEL.PROCESS: this.labelItemKey2.BackColor = Color.Yellow; break; } } }