public class TestWorker
{
private readonly Timer _timer;
public TestWorker()
{
_timer = new Timer(
Callback,
null,
TimeSpan.FromSeconds(1),
TimeSpan.Zero);
}
private void Callback(object state)
{
try
{
//work imitation
Thread.Sleep(5000);
}
finally
{
_timer.Change(
TimeSpan.FromSeconds(1),
TimeSpan.Zero);
}
}
}