T
Tony Johansson
Hello!
I have a completely empty form and the class Form1 below and class Program
shown below.
Now I have created a Timer and can't understand why my event handler
timer_Elapsed for the timer isn't trigged.
public partial class Form1 : Form
{
System.Timers.Timer timer = new System.Timers.Timer();
public Form1()
{
InitializeComponent();
timer.Elapsed += new
System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Interval = 1000;
Enabled = true;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("Testing");
}
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Tony
I have a completely empty form and the class Form1 below and class Program
shown below.
Now I have created a Timer and can't understand why my event handler
timer_Elapsed for the timer isn't trigged.
public partial class Form1 : Form
{
System.Timers.Timer timer = new System.Timers.Timer();
public Form1()
{
InitializeComponent();
timer.Elapsed += new
System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.Interval = 1000;
Enabled = true;
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
MessageBox.Show("Testing");
}
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Tony