With
System.Timers.Timer
you have more options, where
System.Threading.Timer
is a lightweight timer. I would recommend you to use
System.Timers.Timer
Try this ...
using System.Timers;
Timer tmrExecutor = new Timer();
protected override void OnStart(string[] args)
{
tmrExecutor.Elapsed += new ElapsedEventHandler(tmrExecutor_Elapsed);
tmrExecutor.Interval = 5000;
tmrExecutor.Enabled = true;
tmrExecutor.Start();
}
private void tmrExecutor_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
}
protected override void OnStop()
{
tmrExecutor.Enabled = false;
}