1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| public class Chrono
{
public event EventHandler Tick;
private System.Windows.Forms.Timer _timer;
public Chrono()
{
_timer = new System.Windows.Forms.Timer();
_timer.Tick += new EventHandler(Timer_Tick);
_timer.Start();
}
private void Timer_Tick(object sender, EventArgs e)
{ OnTick(new EventArgs()); }
protected virtual void OnTick(EventArgs e)
{ Tick(this, e); }
}
public class MaClasse
{
private Chrono _chrono;
public MaClasse()
{
_chrono = new Chrono();
_chrono.Tick += new EventHandler(Chrono_Tick);
}
private void Chrono_Tick(object sender, EventArgs e)
{ /* ... */ }
} |
Partager