c#: classe System.Threading.Timer

using System.Threading;
...

namespace Nicola.Timer
{
class EsempioTimer
{
static System.Threading.Timer timer;
System.Threading.TimerCallback cb = new System.Threading.TimerCallback(ProcessTimerEvent);

public EsempioTimer() {}

public void Start()
{
timer = new System.Threading.Timer(cb, "", 0, 30000);
}

private static void ProcessTimerEvent(object obj)
{
//...
//...
}

public void Stop()
{
timer.Dispose();
}
}
}

EsempioTimer _et = new EsempioTimer();
_et.Start();
_et.Stop();

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>