Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @if (!IsConnecting)
- {
- <a href="javascript:void(0)" @onclick="Connect">Connect</a>
- }
- else
- {
- <button disabled>Connecting...</button>
- }
- @code {
- bool IsConnecting { get; set; }
- private async Task Connect()
- {
- IsConnecting = true;
- StateHasChanged();
- //Long operation -> it takes a few seconds
- IsConnecting = false;
- StateHasChanged();
- }
- }
- // The disabled button is not shown
- // If I put a return after the first StateHasChanged() -> works
- // If I don't reset IsConnecting to false -> works
- // It seems StateHasChanged() is not called *during* the execution of the method. Only when the function is completed. Why? :(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement