I have a class called Dta that contains the following code:
public event Dta._TimeOutEventHandler _TimeOut;
public delegate void _TimeOutEventHandler(Dta dta);
public void CheckTimeOut()
{
if (TimeOut == null) {
TimeOut = new Timers.Timer();
TimeOut.Interval = 10000;
TimeOut.Start();
TimeOut.Elapsed += TrateTimeOut;
} else {
TimeOut.Stop();
TimeOut.Start();
}
}
private void TimeOut()
{
TimeOut.Stop();
if (_TimeOut != null) {
_TimeOut(this);
}
}
In another class called Monitor, I checked whether the Dot class timeout event occurred with the following code:
_TrateTimeOut += new Dta._TimeOutEventHandler(EncerraPorTimeOut);
However, when the method closesPorTimeOut is called it goes into an infinite loop.
private void EncerraPorTimeOut(){
Console.WriteLine("Metodo Encerrado por TimeOut");
}