日期:2014-05-17  浏览次数:20797 次

一个多线程的问题 ,我个人感觉绝对属于C#的bug,当然也可能是我本身能力太逊,请大家看看,出出主意
之前有个报表的程序,其中有一张报表速度比较慢。所以就加了个多线程。代码大致如下,有个query函数,然后我加了个thread指向他  tempt = new Thread(new ThreadStart(Query)); query函数里面是个while循环,
如下,其中根据 combo_ReportType的值 去做case when

代码如下 
 while (true)
            {
                btn_query.Enabled = false;
                this.dgv_Report.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                String ReportSql = string.Empty;
                switch (combo_ReportType.Text)
                {
                    case "":
                        MessageBox.Show("请选择一个确定的报表!");
                        break;
                    case "急诊就诊量统计":
                        ReportSql = "ReportEmergencyMentimes " + dt_Start.Value.Year.ToString();
                        break;
                    case "急诊就诊量统计按日统计":
                        ReportSql = "ReportEmergencyMentimesByDays " + dt_Start.Value.Year.ToString() + "," + dt_Start.Value.Month.ToString();
                        break;
                    case "急诊留观病人信息表":
                        ReportSql = "OutComeReport " + SqlProcess.SqlProcess.Blank(dt_Start.Value.ToShortDateString()) + "," + SqlProcess.SqlProcess.Blank(dt_End.Value.AddDays(1).ToShortDateString());
                        break;
                    case "急诊死亡病人信息表":
                        this.dgv_Report.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                       &n