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

C#中线程问题,急急急!!!!
void searchAlertInfo()
  {
  searchAlertTable.Rows.Clear();
   
  DataTable tempTable = AlertConsoleBiz.SearchAlertInfo(maxSearchAlertNum, this.ddtpStartTime.Value, this.ddtpEndTime.Value, searchDspID).Tables[0];
  DataRow dr = null;
  Image imgSnap1 = null;
  Image imgSnap2 = null;
  MemoryStream ms1 = null;
  MemoryStream ms2 = null;
   
  int alertCount = 0;
  if (tempTable.Rows.Count >= this.maxSearchAlertNum)
  {
  alertCount = maxSearchAlertNum;
  }
  else
  {
  alertCount = tempTable.Rows.Count;
  }
  Invoke(SetTspMaxDelegate, new object[] { alertCount });
  for (int i = 0; i < alertCount; i++)
  {
  Invoke(TspPerformStepDelegate,null);
  try
  {
  ms1 = new MemoryStream((byte[])dr[7]);
  imgSnap1 = Image.FromStream(ms1);
  ms2 = new MemoryStream((byte[])dr[8]);
  imgSnap2 = Image.FromStream(ms2);
  }
  catch(Exception ex)
  {
  MessageBox.Show(ex.Message);  
  }
  byte[] image1 = (byte[])dr[7];
  byte[] image2 = (byte[])dr[8];
  //给图片添加规则信息,画线,画图
  //画DSP端传过来的矩形  
  Invoke(bindDataSourceDelegate, new object[] { dgvSearchAlert, searchAlertTable });
  Invoke(TspPerformStepDelegate, null);
  Invoke(ResizeDataGridViewDelegate, new object[] { dgvSearchAlert, i });
  }//end of for loop
  ms1.Close();
  ms2.Close();
   
  Invoke(FinishSearchDelegate,alertCount);
  }
以上是我的查询代码,当分辨率为:1024*768时就好使,没问题,如果分辨率该为1028*768时候,查询就出现死机,就是在查询显示图片时死了,请高手指教

------解决方案--------------------
将之前你运行所生成的debug删除,再在分辨率改为1028*768时候运行。
不是thread的问题,因为根据你说的"当分辨率为:1024*768时就好使,没问题",所以因为是你之前调试的时候出现些问题!
祝:
楼主成功!