解决winfrom卡窗口问题
1.在给winfrom窗体控件赋值时,导致窗体卡顿
2.可以使用线程给控件赋值,但是程序报错
3.解决办法如下:
//定义委托
delegate void SetTextCallback(string text);
//异步给input赋值
private void SetTextBox(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetTextBox);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
//在线程里使用此方法
this.SetTextBox(text);