Run async method regularly with specified interval

The async equivalent is a while loop with Task.Delay (which internally uses a System.Threading.Timer): public async Task PeriodicFooAsync(TimeSpan interval, CancellationToken cancellationToken) { while (true) { await FooAsync(); await Task.Delay(interval, cancellationToken) } } It’s important to pass a CancellationToken so you can stop that operation when you want (e.g. when you shut down your application). Now, … Read more

Calling a method every x minutes

var startTimeSpan = TimeSpan.Zero; var periodTimeSpan = TimeSpan.FromMinutes(5); var timer = new System.Threading.Timer((e) => { MyMethod(); }, null, startTimeSpan, periodTimeSpan); Edit – this answer is out of date. See https://stackoverflow.com/a/70887955/426894

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)