We can perform asynchronous calls in a Blazor application using async and await keywords for calling any asynchronous Task or performing any operation.
[Index.razor]
@page "/"
<button @onclick="Compare">Compare</button>
<br />
<p>@content</p>
@code {
public string content = "Some Text";
public async void Compare()
{
await Task.Run(() => TimeOutMethod());
content = "";
await Task.CompletedTask;
}
void TimeOutMethod() => Task.Delay(3000).Wait();
}
Share with