2013-07-17 29 views
1

我有一種方法,其中程序循環通過一個數據加載,我希望它把toolstripstatuslabel1文本loading,但由於某種原因,它完成後它完成加載而不是在加載時。但我的toolStripProgressBar1確實更新正確。我可能會做錯什麼?c#statusstrip toolstripstatuslabel更新過程結束後

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 + "%"; 
     } 
+0

您的意思是第一行'toolStripStatusLabel1.Text =「獲取數據爲:」+ name;'不更新'Label Text'? – Shaharyar

回答

0

這裏的問題是,我在我的UI線程上運行該進程。