The timer does not start without the EventHandler (timerIdle_Tick):
timerIdle.Tick += new EventHandler(timerIdle_Tick);
Follow the timer code after your indication:
class Timers
{
public static System.Windows.Forms.Label lblIdle;
public static Timer timerIdle = new Timer();
public static int segundo = 0;
// TIMER IDLE
public static void timerIdleOn()
{
segundo = 300;
timerIdle.Interval = 1000;
timerIdle.Start();
}
public static void timerIdleOff()
{
timerIdle.Stop();
}
public static void timerIdle_Tick(object sender, EventArgs e)
{
segundo--;
if (segundo == 0)
{
timerIdle.Stop();
dgView.addLinha(2, "config_Teste", "TIMER ACABOU", 0);
}
else
dgView.addLinha(2, "config_Teste", TimeSpan.FromSeconds(segundo).ToString(@"mm\:ss"), 0);
}
}
It follows where the timer is started, I don't use buttons, just one temporarily to test methods, it won't exist afterwards.
namespace HC
{
public partial class frm_console : Form
{
public frm_console()
{
InitializeComponent();
dgView.DataConsole = this.DataConsol;
Timers.timerIdleOn();
}
}
}