我的代码(贴关键部位):
//定义委托
public delegate void UpdateVariable(string[] str);
//定义获取计量间变量数据线程
m_ThreadReadPLCData =new Thread(new ThreadStart(ReadPLCDataFunction));
m_ThreadReadPLCData.Start();private void ReadPLCDataFunction()
{
while (true)
{
//读取登记的变量
string[] str = new string[3];
try
{
//这里对str[]赋值,不贴出来了。
//委托
UpdateVariable uv = new UpdateVariable(UpdateInterface);
this.Invoke(uv, str);//重点来了,就是这一句抛异常:“参数计数不匹配”
}
catch (Exception)
{
}
Thread.Sleep(3000);
}
}
public void UpdateInterface(string[] str)
{
}
//定义委托
public delegate void UpdateVariable(string[] str);
//定义获取计量间变量数据线程
m_ThreadReadPLCData =new Thread(new ThreadStart(ReadPLCDataFunction));
m_ThreadReadPLCData.Start();private void ReadPLCDataFunction()
{
while (true)
{
//读取登记的变量
string[] str = new string[3];
try
{
//这里对str[]赋值,不贴出来了。
//委托
UpdateVariable uv = new UpdateVariable(UpdateInterface);
this.Invoke(uv, str);//重点来了,就是这一句抛异常:“参数计数不匹配”
}
catch (Exception)
{
}
Thread.Sleep(3000);
}
}
public void UpdateInterface(string[] str)
{
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货