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时候,查询就出现死机,就是在查询显示图片时死了,请高手指教

解决方案 »

  1.   

        Invoke(ResizeDataGridViewDelegate, new object[] { dgvSearchAlert, i });
    就是 这行代码:///调用调整datagridview大小的函数
    void ResizeDataGridViewFunction(DataGridView dgv,int rowIndex)
            {
                try
                {
                   //此处问题
                    dgv.AutoResizeRow(rowIndex);(到此处就死)
                  
                    dgv.FirstDisplayedScrollingRowIndex = rowIndex;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
         如果查询5条记录(即alertCount=5)时,当运行到i=3时候就出现死锁。   
      

  2.   

    the case it memory size.