在Blazor(异步任务OnInitializedAsync)生命周期内使用两个wait不会';我不能正常工作

在Blazor(异步任务OnInitializedAsync)生命周期内使用两个wait不会';我不能正常工作,blazor,blazor-client-side,Blazor,Blazor Client Side,我正在手术中使用以下方法 protected override async Task OnInitializedAsync() { forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json"); await someOperation(); // this action is not perfomred } 受保护的重写异步任务OnInitializedAsync

我正在手术中使用以下方法

protected override async Task OnInitializedAsync()
{
    forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
    await someOperation(); // this action is not perfomred
}
受保护的重写异步任务OnInitializedAsync()
{
forecast=wait Http.GetJsonAsync(“sample data/weather.json”);
wait someOperation();//未执行此操作
}

关于此查询的任何建议

我过去曾遇到过此问题,我可以通过以下方式解决此问题:

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
}
受保护的重写异步任务OnInitializedAsync()
{
Http.GetJsonAsync(“sample data/weather.json”).ContinueWith(task=>preferences=task.Result);//创建一个在目标任务完成时异步执行的延续。
wait someOperation();//如果需要,也可以使用ContinueWith完成他的操作
}
文件:


希望这能有所帮助。

最有可能的答案是,第一个呼叫抛出了一个错误,您没有看到,因为它在任务中丢失了。在每个调用周围弹出一个try catch并记录任何错误不,我在第一个调用中没有遇到任何错误,尽管它没有被执行。客户端Blazor或服务器端Blazor?这是一个非同寻常的声明,因此您需要非同寻常的证据。然后发布浏览器控制台日志