0
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 check if the timeout event of the Dta class occurred with the following code:
_TrateTimeOut += new Dta._TimeOutEventHandler(EncerraPorTimeOut);
However when the Encerraportimeout method is called it enters an infinite loop.
private void EncerraPorTimeOut(){
Console.WriteLine("Metodo Encerrado por TimeOut");
}
You can also put the method
EncerraPorTimeOut
in your question?– Leonel Sanches da Silva