I have this timer
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimerMethod);
aTimer.Interval = 5000;
aTimer.Enabled = true;
But when I call this method in timer code,
private void OnTimerMethod(object sender, ElapsedEventArgs e)
{
Response.Write("text");
}
I get this error message
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code
How can I fix this ?
Update :
I see I'm doing wrong but how can I achieve doing this ?
Thanks in advance
I'm trying to make a reminder, so I'll pop some messages at the detected time
You cannot do this by simply writing extra data to a completed response context. The http life cycle doesn't allow for this , at least not in http 1.*. Instead, you would need to (one of):
Your best bet for a reminder is probably just the first one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.