Live Chat Icon For mobile
Live Chat Icon

How can I perform asynchronous calls in a Blazor application?

Platform: Blazor| Category: General

We can perform asynchronous calls in a Blazor application using async and await keywords for calling any asynchronous Task or performing any operation.

Refer to the following code snippet.


@page "/"

<button @onclick="Compare">Compare</button>
<br />

@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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.