【问题标题】:c# statusstrip toolstripstatuslabel updates after the process is overc# statusstrip toolstripstatuslabel在进程结束后更新
【发布时间】:2013-07-17 02:14:14
【问题描述】:

我有一个方法,其中程序循环加载数据,我希望它放入 toolstripstatuslabel1 文本 loading,但由于某种原因,它在加载完成后执行此操作而不是 while它正在加载。但是我的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 + "%";
        }

【问题讨论】:

  • 你的意思是第一行toolStripStatusLabel1.Text = "Acquiringdata for: " + name;不更新Label Text

标签: c# statusbar statusstrip toolstripstatuslabel


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多