使用线程和委托的方式:
using System.Threading;
定义线程和委托
private void button1_Click(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(list1));
thread.IsBackground = true;
thread.Start();
}
private void list1()
{
for (int i = 1; i < 100; i++)
{
Thread.Sleep(500);
this.BeginInvoke(new Action(() =>
{
listBox1.Items.Add(“This is :” + i.ToString());
listBox1.SelectedIndex = listBox1.Items.Count - 1;
}));
}
}
C# Winform Listbox操作,窗体卡顿问题,记录
最新推荐文章于 2024-02-05 11:17:03 发布