110,534
社区成员
发帖
与我相关
我的任务
分享
public class NPort
{
public int Index=0;
public void NPort()
{
}
public void NPort(int i)//重载构造函数
{
Index=i;
//以下执行开启串口等操作
}
}
//实例化类的代码
for(int i=0;i<64;i++)
{
NPort N1=new NPort(i);
}
void Form_load()
{
for(int i=0;i<64;i++)
{
Thread th1=new Thread(fun1);
th1.Start(i);
}
}
void fun1(object o)
{
int i=(int)o;//i就是前面传进来的那个i,对应0-63,用这个索引到全局数组里取串口名称等参数
}