Hi,
you might be interested in:
https://docs.microsoft.com/en-us/dotnet … mework-4.8
Usage is simple:
using System;
using System.Timers;
namespace TimerExample {
class Program {
static Timer mainTimer;
static void Main(string[] args)
{
mainTimer=new Timer(1000); //Set up timer to fire each 1000 milliseconds
mainTimer.Elapsed+=OnMainTimer; //Set method receiving the event
mainTimer.AutoReset=true; //Timer don't fire just once, but will fire repeatedly in gived interval
mainTimer.Enabled=true; //Launch the timer
Console.ReadKey();
mainTimer.Stop(); //Stop the timer
mainTimer.Dispose(); //Dispose it
}
private static void OnMainTimer(object sender, ElapsedEventArgs e)
{
Console.WriteLine("One second passed.");
}
}
}
You can use this principle for example to check every minute, if requested time was reached and react. Just keep in mind, that excepting System.Timers.Timer, there is also System.Threading.Timer, so compiler could give you warnings, if you use the Threading namespace.
Best regards
Rastislav