我有一个主线程,它使两个嵌套的其他线程成为。
private void mainthread()
{
List<Thread> ts= new List<Thread>();
for (int w=0; w<7; w+=2)
for (int h = 0; h < 5; h+=3)
{
Thread t = new Thread(delegate() { otherthreads(w, h); });
ts.Add(t);
t.Start();
}
for (int i = 0; i < ts.Count; i++)
ts[i].Join();
}
private void otherthreads(int w, int h)
{
listBox1.Invoke(new singleparam(addtolistbox), new object[] { "w:" + w.ToString() + ",h:" + h.ToString() });
}
每个线程将其输入参数添加到列表框。我很困惑为什么某些线程的输入参数不在 for 范围内?