日期:2014-05-17 浏览次数:20727 次
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ThreadStart threadStart = new ThreadStart(AddItem);
Thread thread = new Thread(threadStart); //声明一个线程
thread.Start();
}
private void AddItem()
{
for (int index = 0; index < 10000; index++)
{
//this.listBox1.Items.Add(string.Format("Item {0}", index));
this.listBox1.Items.Add(string.Format("item {0}", index));
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show(string.Format("listBox中一共有{0}项", this.listBox1.Items.Count));
}
}
}