主类方法
private void button1_Click(object sender, System.EventArgs e)
{
ThreadMethord tm = new ThreadMethord();
process = new Thread(new ThreadStart(tm.PortScan));
process.Start();
//AddInformation(" TODO: 在此处添加构造函数逻辑");
} protected void AddInformation (string s)
{
MessageBox.Show(s);
this.listBox1.Items.Add(s);
this.textBox1.Text = this.textBox1.Text +s;
this.listBox1.Refresh();
}
基类方法 -------------------------------------------------- public void PortScan()
{
base.AddInformation(" TODO: 在此处添加构造函数逻辑");
}基类ThreadMethord是继承主类Form1的现在我在主类方法button1_Click中创建线程,线程中调用派生类的PortScan()方法,这个方法向主类AddInformation传递更新字符串参数。跟踪一切正常。参数也正确传到了AddInformation我在基类中调用主类的方法。ThreadMethord(string s)但是这个字符串可以用MessageBox.Show来显示,去不能用listbox或TextBox显示。有遇到此问题的朋友请指教一下是怎么回事。谢谢!