//定义更新UI控件的方法 private void UpdatePosition(Control control, string txt) { if (control.InvokeRequired) { this.BeginInvoke((EventHandler) delegate { while (!control.IsHandleCreated) { if (control.Disposing || control.IsDisposed) { return; } } SetXPosHandle set = new SetXPosHandle(UpdatePosition); control.Invoke(set, new object[] { control, txt }); }); } else { control.Text = txt; } }
//定义更新UI控件的方法 private void UpdatePosition(string txt) { if (this.txtXLocation.InvokeRequired) { this.BeginInvoke((EventHandler) delegate { while (!this.txtXLocation.IsHandleCreated) { if (this.txtXLocation.Disposing || this.txtXLocation.IsDisposed) { return; } } SetXPosHandle set = new SetXPosHandle(UpdatePosition); this.txtXLocation.Invoke(set, new object[] { txt }); }); } else { this.txtXLocation.Text = txt; } }