Realtime updating DateTime/Data

Good morning @Team,

Recently, I was struggling with updating the DateTime in realtime using Blazor server-side. I managed to fix this with the code below. But it feels like there must be a more simpler way to make these kinds of things realtime.

@code {     private string ActualTime { get; set; } = DateTime.Now.ToLongTimeString();
            private string ActualDate { get; set; } = DateTime.Now.ToShortDateString();

        protected override async Task OnInitializedAsync()
            var timer = new Timer(new TimerCallback(_ =>
                ActualTime = DateTime.Now.ToLongTimeString();
                ActualDate = DateTime.Now.ToShortDateString();

            }), null, 500, 500);

I also want to update values from the MSSQL database in realtime (or even event-based). Is there a simpler way to implement realtime data within Radzen or do I need to make custom code and make use of libraries like SignalR?

BTW: I want to update data that is stored within a RadzenLabel component.

Looking forward to hearing from you!

1 Like

Radzen does not provide anything simpler for real-time communication. Using a timer to refresh the data or another library such as SignalR is the recommended approach.

@korchev Thanks for the reply, will look into that then!