线程中不要直接控制UI控件,你可以把数据算好,然后通过委托去通知UI更新

解决方案 »

  1.   


            public delegate DoProcess(Chart inputchart,int chartindex,int pointIndex);
            private void RefreshUI(Chart inputchart,int chartindex,int pointIndex)
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new DoProcess(RefreshMainform), new object[]{inputchart,chartindex,pointIndex});
                }
                else
                {
                    inputchart.ChartAreas["Default"+chartindex].AxisX.Maximum = pointIndex;
                }
            }        public void threadDo()
            {
                 if (chart1.ChartAreas["Default1"].AxisX.Maximum < pointIndex)
                 {
                     RefreshUI(chart1, 1, pointIndex);
                 }
                if (chart2.ChartAreas["Default2"].AxisX.Maximum < pointIndex)
                {
                    RefreshUI(chart2, 2, pointIndex);
                }
                if (chart3.ChartAreas["Default3"].AxisX.Maximum < pointIndex)
                {
                    RefreshUI(chart3, 3, pointIndex);
                }
            }