代码如下:<%@ Application Language="C#" %><script runat="server">
void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer(1000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
myTimer.Interval = 1000;
myTimer.Enabled = true; }
void Application_End(object sender, EventArgs e)
{
// 在应用程序关闭时运行的代码 }
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码 } void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码 } void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
// InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。 }
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
msg.birthday_tx(); // msg类的一个生日短信发送函数
}
</script>问题描述:
把 msg.birthday_tx()直接放在 Application_Start下面可以工作,但是经过定时器调用失败,不明白那里出了问题了。
void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer(1000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
myTimer.Interval = 1000;
myTimer.Enabled = true; }
void Application_End(object sender, EventArgs e)
{
// 在应用程序关闭时运行的代码 }
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码 } void Session_Start(object sender, EventArgs e)
{
// 在新会话启动时运行的代码 } void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
// InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。 }
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
msg.birthday_tx(); // msg类的一个生日短信发送函数
}
</script>问题描述:
把 msg.birthday_tx()直接放在 Application_Start下面可以工作,但是经过定时器调用失败,不明白那里出了问题了。
解决方案 »
- 求关于div显示的问题
- 设置Response.ContentType = "application/octet-stream";后下载的文本文件为空字节?请高手帮忙诊断!
- 和大家交流Asp.net界面開發心得
- 高分求解 怎么在WEB页面上实现对权限的管理
- 高分 点击imagebutton(ibtnDelete)怎么没反应? 请帮忙看看
- 一个关于DataBind的问题
- windows xp Pro版本的ISS中,怎么没有新建站点一项呀?
- 无聊呀,散10分
- MVC数据库问题
- 一个使用用户空间控制流程的问题,望各位帮忙解答,小弟感谢不尽,在线等待
- asp.net中的fileupload控件的ftp下载
- 关于自定义表格绑定到gridview上的问题..求大虾帮忙
{
System.Timers.Timer myTimer = new System.Timers.Timer(60000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
myTimer.Interval = 6*1000;
myTimer.Enabled = true;
}
private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
string date = DateTime.Now.ToString();
}
//时间稍微设置长一点