Question: I am currently working on a Blazor project and facing with a bug. The plan is to update a component in every second, as long as the for loop updates. My problem is a bit complex, so I reproduced this bug in another project:

The Calculate.cs file where the calculations happen:

```
public class Calculate
{
    public void Calc(Index index)
    {
        for (int i = 0; i < 10; i++)
        {
            Thread.Sleep(1000);
            index.Update(i);
        }
    }
}

```

The index.razor file:

```
<button class="btn btn-primary" @onclick="Test">Click me</button>

<p>Test number: @testNumber</p>

@code
{
    private int testNumber;
    Calculate c = new Calculate();

    public void Test()
    {
        c.Calc(this);   
    }
    public void Update(int i)
    {
        testNumber = i;
        Debug.WriteLine(i);
    }
}

```

After testing, the Debug Console prints the numbers as it should in every second, all the way from 0-9, but the opened Blazor display only prints the 9, whenever the calculations and the 10 seconds are over.

Answer: 
Add this to your for loop code.

```
StateHasChanged();

```

Forces a refresh.

I have a sample that does simple animations if you want to look at my sprite component:

<https://github.com/DataJuggler/DataJuggler.Blazor.Components>

And a video is here:

<https://www.youtube.com/watch?v=frtetHgfdIo>
Have you tried to assign `i`'s value to a temp variable inside the for-loop like below?:

```
var counter = i;
index.Update(counter);

```