提问
blazor如何设置定时任务刷新页面
回答
1.使用Timer
2. 触发页面状态已经改变
InvokeAsync(StateHasChanged);
protected override async Task OnInitializedAsync()
{
try
{
base.OnInitialized();
//TODO
var timer = new Timer(_ =>
{
InvokeAsync(() => //TODO);
InvokeAsync(StateHasChanged);
}, null, 500, 3000);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
标签:InvokeAsync,Timer,刷新,blazor,定时,页面
From: https://www.cnblogs.com/wuhailong/p/17326088.html