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#..)
myTimer.Start();
And to call your method when it ticks, use
/* Adds the event and the event handler for the method that will process the timer event to the timer. */
myTimer.Tick += new EventHandler(TimerEventPro
Where TimerEventProcessor is the name of your function. All taken from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsTimerClassTickTopic.asp