110,538
社区成员
发帖
与我相关
我的任务
分享
///线程函数
private void threadFunc()
{
string[] infos = new string[10];
for (int i = 0; i < 10; i++)
{
infos[i] = "mess:" + i.ToString();
}
ShowArray(infos);
}
///委托刷新
private void ShowArray(string[] info)
{
this.Invoke(new Action(() => {
listBox1.Items.Clear();
for (int i = 0; i < info.Length; i++)
{
listBox1.Items.Add(info[i]);
}
}));
}
///启动线程
System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(threadFunc));
th.IsBackground = true;
th.Start();