New to Blazor,
I am working with the Login via API, however I noticed that the UI doesn't update automatically.
For example: When I logged in an invalid user for the first time, the error message doesn't display, but on the 2nd try it will display correctly. Somehow has 1 click delay.
private async void DoLogin()
{
var result = await API.LoginAsync(username, password);
if (result.ResultID == 0)
{
}
else
ErrorMessage = result.ErrorMessage;
}
When I changed it to
private async Task DoLogin()
{
var result = await API.LoginAsync(username, password);
if (result.ResultID == 0)
{
}
else
ErrorMessage = result.ErrorMessage;
}
It is working as expected.
Can someone shed a light
- What's the difference using async void and async Task in Method signature?
- Why does the async void doesn't update the UI immediately?
