110,536
社区成员
发帖
与我相关
我的任务
分享
VEL_textBox.Text = VEL.ToString();
this.BeginInvoke(new Action(() =>
{
VEL_textBox.Text = VEL.ToString();
}));
2、如p哥所说,使用INotifyPropertyChanged
public partial class FormTest : Form, INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private string bindingValue;
public string BindingValue
{
get { return bindingValue; }
set
{
bindingValue = value;
if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("BindingValue"));
}
}
//首次绑定
private void button55_Click(object sender, EventArgs e)
{
BindingValue = "aaaa";
label14.DataBindings.Add("Text", this, "BindingValue", false, DataSourceUpdateMode.OnPropertyChanged);
}
//后续修改
private void button56_Click(object sender, EventArgs e)
{
BindingValue = "33333333";
}
while(1)
VEL_textBox.Text = VEL.ToString();
[/quote]
非UI线程更新控件值,没报错吗?!
就算去掉线程验证没报错,那也是死循环,能不卡顿麽[/quote]
实时检测采集的变量 double VEL并显示在VEL_textBox.Text上面.
主界面显示 进程1采集数据 进程2更新VEL_textBox.Text.不操作界面不死机.一操作界面就死了.
VEL_textBox.Text = VEL.ToString();
[/quote]
线程是什么鬼?while(1)
VEL_textBox.Text = VEL.ToString();
[/quote]
非UI线程更新控件值,没报错吗?!
就算去掉线程验证没报错,那也是死循环,能不卡顿麽while(1)
VEL_textBox.Text = VEL.ToString();
VEL_textBox.Text = VEL.ToString();
while(1)
VEL_textBox.Text = VEL.ToString();
[/quote]
非UI线程更新控件值,没报错吗?!
就算去掉线程验证没报错,那也是死循环,能不卡顿麽[/quote]
你说的对的,我理解了,加了begininvoke操作 再加延时函数避免CPU占用过多.
这个有机会看下.