问:虚拟主机中Global文件System.Timers.Timer定时任务只执行有限的四五次,为何?
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Timers;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using WebApplication3.App_Code;
namespace WebApplication3
{
public class Global : System.Web.HttpApplication
{
protected void timer_Elapsed(object sender, ElapsedEventArgs e)
{
Class1.a();
}
protected void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer;
timer.Elapsed = timer_Elapsed;
timer.Enabled = true;
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Timers;
using System.Web;
namespace WebApplication3.App_Code
{
public class Class1
{
public static void a()
{
FileStream fs = File.Open(System.AppDomain.CurrentDomain.BaseDirectory.ToString() ("b.txt"), FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(DateTime.Now.ToString());
sw.Close();
fs.Close();
}
}
}
以上代码,本地一切正常,上传到虚拟主机后,却只执行2-6次之间,之后,就不在执行了?,虚拟主机中Global文件System.Timers.Timer定时任务
答:您好,请提供对应主机信息和测试url查看下,非常感谢您长期对我司的支持!
问:
答:您好,调整为了32位进程池模式,现在查看执行多次,非常感谢您长期对我司的支持!