[英]Error calling non-static method
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
System.Web.dll中发生类型'System.Web.HttpException'的异常,但未在用户代码中处理
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.*.
http生命周期不允许这样做 ,至少在http 1. *中不允许 。 Instead, you would need to (one of):
相反,您将需要(以下一项):
Your best bet for a reminder is probably just the first one. 提醒您的最佳选择可能只是第一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.