currently facing this issue with a timer. I basically want to create a timer which will execute after a button press. this will then count to 5 and then close the window which is created from the class. Below is what I have at the moment.
public void startMessageIndicator(string message, bool completed)
{
messageIndicator.Text = "completed";
window.Show();
aTimer = new System.Timers.Timer(5000);
aTimer.Enabled = true;
aTimer.Start();
aTimer.Elapsed += new ElapsedEventHandler(timerElapsed);
aTimer.AutoReset = true;
}
public void timerElapsed(object sender, ElapsedEventArgs e)
{
window.Close();
st.Clear();
aTimer.Enabled = false;
}
When I compile the code I face no issues however when I go into the debugger and use breakpoints it does not seem to run window.close() and just gets stuck on that line.
Any ideas what I am doing wrong