這裏是我的示例代碼:RichTextBox的不跨線程操作更新
//------this is just GUI Form which is having RichTextBox (Access declared as Public)
//
public partial class Form1 : Form
{
public void function1()
{
ThreadStart t= function2;
Thread tStart= new Thread(t);
tStart.Start();
}
public void function2()
{
//Calling function3 which is in another class
}
}
//------this is just Class, not GUI Form
class secondClass: Form1
{
public void function3()
{
Form1 f =new Form1();
//Updating the RichTextBox(which is created in Form1 GUI with Public access)
f.richTextBox1.AppendText("sample text");
}
}
我試圖通過調用richTextBox1
控制和運行我的代碼沒有錯誤,但richtextbox
是不會得到更新。
我需要做什麼來更新我的狀態從richTextBox
頻繁從另一個類功能?