Hi
I love the RadZen UI and I think a timer component would add another level to the system. I know it's possible to do a timer in c# but a built in component would just make it so much easier.
Please keep up the good work this product is awesome.
Hi
I love the RadZen UI and I think a timer component would add another level to the system. I know it's possible to do a timer in c# but a built in component would just make it so much easier.
Please keep up the good work this product is awesome.
Hi @Penfold,
At the moment we offer only UI components in Radzen toolbox and indeed to create a timer is very easy - check this thread for reference:
Finally took a crack at this and thought I might share my code. This simply sets a Property called MyProperty to the current time every second and then runs the StateHasChanged(). To do this you just need to edit your Page's razor.cs file and add the code:
namespace <yourprojectname>.Pages
{
public partial class <PageName>Component
{
System.Timers.Timer timer = new System.Timers.Timer();
protected override void OnInitialized()
{
base.OnInitialized();
timer.Interval = 1000; // 1 second in milliseconds
timer.Elapsed += OnTimedEvent;
timer.AutoReset = true;
timer.Enabled = true;
}
private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
{
InvokeAsync(() =>
{
MyProperty = DateTime.Now.ToString();
StateHasChanged();
});
}
}
}