How to execute a method periodically from WPF client application using threading or timer [closed]

I would recommend the System.Threading.Tasks namespace using the new async/await keywords. // The `onTick` method will be called periodically unless cancelled. private static async Task RunPeriodicAsync(Action onTick, TimeSpan dueTime, TimeSpan interval, CancellationToken token) { // Initial wait time before we begin the periodic loop. if(dueTime > TimeSpan.Zero) await Task.Delay(dueTime, token); // Repeat this loop until … Read more