Link to home
Start Free TrialLog in
Avatar of Palamedes
PalamedesFlag for United States of America

asked on

C#: Catching an event from a timer in a class

There needs to be a C# forum.

I have created a class in which I need a timer.  Something like this;

public class myClass
{
  public System.Windows.Forms.Timer  myTimer;
  myTimer = new System.Windows.Forms.Timer();
  myTimer.interval = 1000;
  myTimer.enabled = true;
}

How do I now catch that tick event?

This timer isn't a form anywhere so I created it dynamically..  This works as it does in delphi but damn if I know how to catch that event.

A timer I dropped on my form just for testing purposes gave me an event like this;

private void myTimer_tick(object sender, System.EventArgs e)
{
  // Do thing here
}

But somewhere I must attach myTimer to the myTimer_tick event..   How do I do this?  (This is probably very simple.. I'm new to C#..)
ASKER CERTIFIED SOLUTION
Avatar of IainHere
IainHere

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Palamedes

ASKER

That did the trick!   Thanks a bunch..