I have timer
that I'm testing and it returns me an error:
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code
Additional information: Response is not available in this context.
private static System.Timers.Timer timer;
protected void btnGerarArquivo_Click(object sender, EventArgs e)
{
timer = new System.Timers.Timer();
timer.Interval = 60;
timer.Elapsed += new ElapsedEventHandler(Teste);
timer.Enabled = true;
}
public void Teste(object source, ElapsedEventArgs e)
{
try
{
Response.Write("teste");
timer.Enabled = false;
}
catch (Exception ex)
{
Response.Write("erro " + ex.Message);
}
}
Afterthesettingsgotthisway,mostdonotrefreshthescreen:
System.Threading.TimertTime;protectedvoidbtnGerarArquivo_Click(objectsender,EventArgse){tTime=newSystem.Threading.Timer(newTimerCallback(Teste),null,15000,6000);}publicvoidTeste(objectsender){horaCriacaoPagina.Text="Hora atualizada : " + DateTime.Now.ToLongTimeString();
}