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();
InvokeAsync(StateHasChanged);
}), 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!