-1

I creat a class with a variable of timer.I want to declare its tick event ,allowing other class use the event.How can I do that?

Class a
{
    protected System.Windows.Forms.Timer bindTimer;
}
shadowfish
  • 109
  • 4

1 Answers1

0

You can write this:

class a
{
  protected System.Windows.Forms.Timer bindTimer;

  public event EventHandler OnTimer;

  private void Timer_Tick(object sender, EventArgs e)
  {
    OnTimer(sender, e);
  }

  public a()
  {
    bindTimer.Tick += Timer_Tick;
  }
}