Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

.NET Maui Hybrid, Blazor Update UI mid method

$
0
0

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.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>