过程结束后,c#statusstrip toolstripstatuslabel更新

时间:2013-07-17 02:14:15

标签: c# statusbar statusstrip toolstripstatuslabel

我有一种方法,程序循环访问大量数据,我希望它放在toolstripstatuslabel1文本loading中,但出于某种原因,它在完成加载后执行此操作而不是在加载时。但我的toolStripProgressBar1确实正确更新。我可能做错了什么?

toolStripStatusLabel1.Text = "Acquiringdata for: " + name;
toolStripProgressBar1.Minimum = 0;
toolStripProgressBar1.Value = 1;
toolStripProgressBar1.Step = 1;

        for (int i = 8; i < data.Count; i++)
        {
            string newstr = data[i];
            string date = newstr.Substring(0, newstr.IndexOf(","));
            newstr = newstr.Substring(newstr.IndexOf(",") + 1);
            string close = newstr.Substring(0, newstr.IndexOf(","));
            newstr = newstr.Substring(newstr.IndexOf(",") + 1);
            string high = newstr.Substring(0, newstr.IndexOf(","));
            newstr = newstr.Substring(newstr.IndexOf(",") + 1);
            string low = newstr.Substring(0, newstr.IndexOf(","));
            newstr = newstr.Substring(newstr.IndexOf(",") + 1);
            string open = newstr.Substring(0, newstr.IndexOf(","));
            newstr = newstr.Substring(newstr.IndexOf(",") + 1);
            string volume = newstr.Substring(0);

            DataPoint dp = new DataPoint(date, close, high, low, open, volume);
            dataPoints.Add(dp);

            richTextBox1.Text += "New DataPoint Added: \n";

            toolStripProgressBar1.PerformStep();
            toolStripStatusLabel2.Text = (double)(i / (data.Count - 8))*100 + "%";
        }

1 个答案:

答案 0 :(得分:0)

这里的问题是我在我的UI线程上运行该进程。