我有,我需要在一个线程的形式运行中更新的文本,但不能工作究竟如何,这将是acheivable的问题,这是我现有的代码:更新文本从另一个
public partial class Class1: Form
{
LoadText = loadText;
ResourceName = resourceName;
static private void ShowForm()
{
LoadForm = new Class1(LoadText, ResourceName);
Application.Run(LoadForm);
}
static public void ShowLoadScreen(string sText, string sResource)
{
LoadText = sText;
ResourceName = sResource;
Thread thread = new Thread(new ThreadStart(Class1.ShowForm));
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
}
现在我需要改变在新开工的形式下一个文本框中的文本,这需要从理论“的Class2”执行:
class Class2
{
public void UpdateThreadFormTextbox
{
Class1.ShowLoadScreen("text", "text");
//Change textbox in the thread instance of Class1 form
}
}
我已经研究过使用“调用”,但我不能使用从Class2中,确实有一个解决方案,使我能够更新Class1线程实例fr中的文本om Class2?
Ed以显示全局变量。 –
上面的代码不正确,LoadText和ResourceName是什么类型,UpdateThreadFormtextbox也是一个方法,但没有括号括号。 – ColinM