我想在线程列表中运行具有不同值的类。像这样:线程输入参数
int index = 0;
foreach (TreeNode nd in tvew.Nodes[0].Nodes)
{
threadping[index] = new Thread(delegate()
{ this.Invoke(new DelegateClientState(InvokeCheckNetworkState), new object[] {nd}); });
threadping[index].Name = nd.Name;
threadping[index].IsBackground = true;
threadping[index].Start();
index++;
}
但是当我调试代码时,我看到类参数只是最后一个值。 我的意思是,当我通过线程类时,我发现每次运行输入参数的值都是最后一个线程的最后一个值。
有人可以告诉我为什么?
你可以显示你已经初始化threadPing集合的代码。什么是“类参数”或者你正在调试什么线程类? –