How to update server-side changes on the client side for Blazor Server app?

前端 未结 1 679
Happy的楠姐
Happy的楠姐 2020-12-16 07:57

My ChangeValues server-side event occurs every 5 seconds but on client-side, I only see the first value of the number variable. See code be

相关标签:
1条回答
  • 2020-12-16 08:40

    When you use a Timer (that will fire on another Thread) you have to call StateHasChanged() using Invoke:

    private async void DoWork(object state)
    {
        ChangeValues();
        await InvokeAsync(StateHasChanged);        
    }
    
    0 讨论(0)
提交回复
热议问题