-
-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
之前是在NET6.0环境中,可以正常显示数据,升级到NET8.0后,无法正常显示数据。
HubConnection的On方法中调用Table的QueryAsync()方法的代码如下
hubConnection.On<string, List<DeviceTagInfo>>("ReceiveDeviceVariablesNotify", async (deviceName, deviceTagInfos) =>
{
if (deviceName == DeviceName)
{
var encodedMsg = $"Device KeyPairs: {deviceTagInfos}";
DeviceTagInfos = deviceTagInfos;
await TableElement.QueryAsync();
}
});Table的OnQueryAsync事件的实现如下
private async Task<QueryData<DeviceTagInfo>> OnQueryAsync(QueryPageOptions options)
{
List<DeviceTagInfo> items = DeviceTagInfos;
// 设置记录总数
var total = items.Count();
// 内存分页
items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems).ToList();
return new QueryData<DeviceTagInfo>() { Items = items, TotalCount = total };
}执行完OnQueryAsync所有方法后,VS自动进入以下部分进行报错。

通过测试,把BootstrapBlazor的Table组件中的QueryAsync方法中 ,StateHasChanged 换成异步调用就可以了,await InvokeAsync(StateHasChanged);
private async Task QueryAsync(bool shouldRender, int? pageIndex = null)
{
if (ScrollMode == ScrollMode.Virtual && VirtualizeElement != null)
{
await VirtualizeElement.RefreshDataAsync();
}
else
{
await InternalToggleLoading(true);
if (pageIndex.HasValue)
{
PageIndex = pageIndex.Value;
}
await QueryData();
await InternalToggleLoading(false);
}
if (shouldRender)
{
//StateHasChanged
//此部分换成异步调用
await InvokeAsync(StateHasChanged);
}
}Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working