hai ragione...
codice:
namespace Delegates
{
using System.Collections;
using System.Timers;
using System.Windows.Forms;
class Ticker
{
public delegate void Tick(int hh, int mm, int ss);
public event Tick tick;
public Ticker()
{
this.ticking.Elapsed += new ElapsedEventHandler(this.OnTimedEvent);
this.ticking.Interval = 1000; // 1 second
this.ticking.Enabled = true;
}
private void Notify(int hours, int minutes, int seconds)
{
if (this.tick != null)
{
this.tick(hours, minutes, seconds);
}
}
private void OnTimedEvent(object source, ElapsedEventArgs args)
{
int hh = args.SignalTime.Hour;
int mm = args.SignalTime.Minute;
int ss = args.SignalTime.Second;
Notify(hh, mm, ss);
}
private System.Timers.Timer ticking = new System.Timers.Timer();
}
}