窗体代码:
public partial class MainFrame : Form
{
private static XmlDocument xmlDoc = new XmlDocument();
public MainFrame()
{
InitializeComponent();
}
GetTime dt = new GetTime();
public void start()
{
readLog("System Start Running......\n");
readLog("数据库连接成功......\n");
AutoProcessThread autopt = new AutoProcessThread();
Thread td = new Thread(autopt.run);
//运行一个cs文件中的方法
td.Start();
}
public void readLog(string log)
{
string time = dt.dateTime();
textBox1.AppendText(time + log + "\n");
}
}
}
class AutoProcessThread
{
public void run()
{
MainFrame mf= new MainFrame();
mf.readLog("进入autoProcess------run");
}
}
那么问题来了,为什么窗体中调用readLog方法就能显示在textBox中,而其它cs文件调用 mf.readLog("进入autoProcess------run") 没有显示在窗体的textBox上呢?