I have a method that takes a few seconds to process. When a button is clicked I'd like it to update the UI to show processing, and then when the method has finished to change the UI. As an example, I have taken the boiler plate code and modified the counter click to the following:
@page "/counter"<h1>Counter</h1><p role="status">Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">@ButtonText</button>@code {private int currentCount = 0;private string ButtonText = "Click";private void IncrementCount(){ ButtonText = "Running"; StateHasChanged(); currentCount++; Thread.Sleep(1000); ButtonText = "Click"; StateHasChanged();}}I clearly don't understand the thread processing or something. In the example, the button text does not change.
Running .NET 9 Maui Hybrid.