日期:2014-05-18  浏览次数:20810 次

关于委托,抛的“参数计数不匹配”异常,又来求助大家了!
我的代码(贴关键部位):
//定义委托
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)
{
}

------解决方案--------------------
this.Invoke(uv, (Object)str);