托管调试助手“ContextSwitchDeadlock”在“E:\skyrag\FlashLive\FlashLive\bin\Debug\酷闪.vshost.exe”中检测到故障。
其他信息: CLR 无法从 COM 上下文 0x1a0598 转换为 COM 上下文 0x1a0708,这种状态已持续 60 秒。拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个运行时间非常长的操作。这种情况通常会影响到性能,甚至可能导致应用程序不响应或者使用的内存随时间不断累积。要避免此问题,所有单线程单元(STA)线程都应使用泵式等待基元(如 CoWaitForMultipleHandles),并在运行时间很长的操作过程中定期发送消息。

解决方案 »

  1.   

    我也遇到了,盼高手赐教
    重复调用此函数,当记录很多时才报这个错误
    代码:
    public string[][] particular(string area,string office, DateTime start, int days)
            {
                DateTime tempTime = start.AddDays(days);
                string sql = "select substr(phone,6),id,name,phone,to_char(operationtime,'yyyy-mm-dd hh24:mi:ss'),khmethod ";
                sql += "from lanpo." + area + "gd where operationtype='装' and area='"+office+"' and operationtime between to_date('";
                sql += start + "','yyyy-mm-dd hh24:mi:ss') and to_date('" + tempTime + "','yyyy-mm-dd hh24:mi:ss')";
                string sql1 = "select count(*) from lanpo." + area + "gd where operationtype='装' and area='" + office + "' and operationtime between to_date('";
                sql1 += start + "','yyyy-mm-dd hh24:mi:ss') and to_date('" + tempTime + "','yyyy-mm-dd hh24:mi:ss')";
                OracleDataReader odr;
                OracleDataReader odr1;
                string tel = "";
                string[][] result;
                
                    odr = selectDB(sql);
                    odr1 = selectDB(sql1);                odr1.Read();
                    int count = int.Parse(odr1.GetOracleNumber(0).ToString());
                    result = new string[count][];                int k = 0;
                    while(odr.Read())
                    {
                        result[k] = new string[6];
                        result[k][1] = odr.GetOracleNumber(1).ToString();
                        result[k][2] = odr.GetOracleString(2).ToString();
                        result[k][3] = odr.GetOracleString(3).ToString();
                        result[k][4] = odr.GetOracleString(4).ToString();
                        result[k][5] = odr.GetOracleString(5).ToString();
                        
                        char[] ch = odr.GetOracleString(0).ToString().ToCharArray(); 
                        tel = "";
                        for (int i = 0; i < ch.Length; i++)
                        {
                            switch (ch[i])
                            {
                                case '0': tel += "0"; break;
                                case '1': tel += "1"; break;
                                case '2': tel += "2"; break;
                                case '3': tel += "3"; break;
                                case '4': tel += "4"; break;
                                case '5': tel += "5"; break;
                                case '6': tel += "6"; break;
                                case '7': tel += "7"; break;
                                case '8': tel += "8"; break;
                                case '9': tel += "9"; break;
                            }
                        }
                        sql1 = "select nvl(sum(charge),0) from lanpo." + area + "cdr where substr(called,6) = '" + tel + "' and starttime between to_date('";
                        sql1 += start + "','yyyy-mm-dd hh24:mi:ss') and to_date('" + tempTime + "','yyyy-mm-dd hh24:mi:ss')";
                        //System.Windows.Forms.MessageBox.Show(sql1);
                        odr1 = selectDB(sql1);
                        if (odr1.Read())
                        {
                            result[k++][0] = odr1.GetOracleNumber(0).ToString();                       
                        }
                    }
                    return result;        
                
            }