XAML timer

Skythrust

Member
Jul 9, 2019
120
6
Hi there!

I was wondering if xaml does have an option to have a timer. For example to update the current (real) time every 5 seconds)

I have tried this code below but without success.

C#:
public void UpdateValues()
{
    System.Timers.Timer tValueUpdater = new System.Timers.Timer();
    tValueUpdater.Interval = 500;
    tValueUpdater.Elapsed += OnTimedEvent;
    tValueUpdater.Enabled = true;
}

private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
    resc.GetLiveTemperature();
    resc.GetValues();
    AppDesigner();

    lHeaderFooter.Text = DateTime.Now.ToString();

}
 

JayCustom

Always Learning
Aug 8, 2013
5,431
1,344
XAML - Utilizing C#? Like WPF?

You would just bind to a variable, that you could update on a timer, or spawn a background task that updates the variable in a while loop?

I believe the standard practice is using a WPF DispatcherTimer
 

Users who are viewing this thread

Top