【发布时间】:2014-05-14 11:18:45
【问题描述】:
我正在使用一个线程运行此代码:
try
{
Form1 f = getForm<Form1>();
f.changePrice(price);
}
catch (Exception e)
{
Console.WriteLine("error: " + e);
}
这里是changePrice 方法:
public void changePrice(Int32 price)
{
txtPrice.Text = ""+price;
}
我想在我的文本框“txtPrice”中添加文本。
【问题讨论】:
-
将空字符串添加到整数?请开始阅读。
-
changePrice与owns和Form1使用的是同一线程吗?您不能以这种方式从其他线程更改Control的属性。 -
它正在被另一个线程使用,Kamil 有什么建议吗?
-
你不能那样做,使用这里描述的方式:stackoverflow.com/questions/661561/…
-
错误信息究竟是什么意思?
标签: c# multithreading forms user-interface invalidoperationexception