【线程相关】不知是我程序的问题还是微软BUG
本帖最后由 lanzhenkai 于 2012-12-13 17:52:13 编辑 我用的线程调用一个方法这个方法有两个参数
if (buf[0] == 0xF5)
{
if (index >= 7)
{
length = buf[6] + 9;
if (index == length)
{
td = new Thread(delegate() { Panduan(buf, index); });
//注意着个Panduan()的方法 有两个参数 一个是BUF 一个是I
td.IsBackground = true;
td.Start();
index = 0;
length = 0;
}
else if (index > length)
{
index = 0;
length = 0;
}
}
}
else
{
index = 0;
length = 0;
Thread.Sleep(50);
}
public void Panduan(byte[] content,int index)
{
//这个方法有两个参数 也就是上面线程调用方法的时候传过来的参数
}
if (index == length)
{
int i = index;
td = new Thread(delegate() { Panduan(buf, i); });
td.IsBackground = true;
td.Start();
index = 0;
length = 0;
}