private System.Timers.Timer aTimer;
private void StartTimer(double intervalInMilleseconds)
{
aTimer = new System.Timers.Timer(intervalInMilleseconds);
aTimer.Elapsed += (sender, args) => someMethod();
aTimer.Enabled = true;
}
private void someMethod()
{
aTimer.Enabled = false;
Console.WriteLine("method called");
aTimer.Enabled = true;
}
Somewhere, call: StartTimer(#intervalInMilleseconds);
For anything other than "demo" purposes, I think the suggestion here to use WindowsScheduler is the best strategy.
And, have you thought about how you will terminate your application: you better :)