Momerath said:
How long do you think it takes your computer to count to 1000? Let's say your loop take 2 clock cycles per iteration (increment i, store i) and you have a 2Ghz CPU. So we have 2000 clock cycles with a computer that is doing 2,000,000,000 cycles per second. That works out to be 1 millionth of a second. So you aren't going to see much.
Given that, if you really want to watch it count, create a timer object and increment the lable1.Text in the event trigger. That way you can set the speed at which you want it to increment.
But i used sleep(1000) command after "label1.Text = i.ToString();", it didn't show. I think i have to use backgroundWorker. But i don't have enough information about that. I can send integers, but i need to send strings and arrays. I didn't get the logic exactly.
Here is my code but it's sending just integers;
private void Form1_Load(object sender, System.EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 100; i++)
{
backgroundWorker1.ReportProgress(i);
Thread.Sleep(100);
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
box.Text = e.ProgressPercentage.ToString();
}