0
votes

I am using the following method in an operation.

protected override async Task OnInitializedAsync()
{
    forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
    await someOperation(); // this action is not perfomred
}

Any suggestion on this query

1
most likely answer is that the first call is throwing an error which you don't see because its lost in the Task. pop a try catch around each call and log any errors - Mister Magoo
No, i didn't face any errors in the first call, though it is not executed. - INDRA JITH
Client side Blazor or Server side Blazor? - Mister Magoo
This is an extraordinary claim so you need extraordinary proof. - Henk Holterman
and post the browser console log - agua from mars

1 Answers

1
votes

I have had this issue in the past and I was able to fix it like:

protected override async Task OnInitializedAsync()
{
    Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json").ContinueWith(task => forecasts = task.Result); //Creates a continuation that executes asynchronously when the target Task completes.


    await someOperation(); // his action can also be done using ContinueWith if needed
}

ContinueWith Doc:

Hope this helps.