Hello,
I've been looking into the Timer class (http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx), but the thing about the timer is, it's on going. Is there a way to stop it after one go? or after 5 go's?
Right now i am doing the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
namespace TimerTest
{
class Program
{
private static System.Timers.Timer aTimer;
static void Main(string[] args)
{
DoTimer(1000, delegate
{
Console.WriteLine("testing...");
aTimer.Stop();
aTimer.Close();
});
Console.ReadLine();
}
public static void DoTimer(double interval, ElapsedEventHandler elapseEvent)
{
aTimer = new Timer(interval);
aTimer.Elapsed += new ElapsedEventHandler(elapseEvent);
aTimer.Start();
}
}
}