我在类文件中使用定时器和线程,然后在全局文件中调用这个类文件。如果定时器调用那么它会影响网站的其他进程吗???
我的代码如下:
public void Scheduler_Start()
{
Thread thread = new Thread(new ThreadStart(ThreadFunc));
thread.IsBackground = true;
thread.Name = "ThreadFunc";
thread.Start();
}
protected void ThreadFunc()
{
System.Timers.Timer t = new System.Timers.Timer();
t.Interval = 24 * 60 * 60 * 1000;
t.Enabled = true;
t.AutoReset = true;
t.Start();
t.Elapsed += new System.Timers.ElapsedEventHandler(TimerWorker);
}
protected void TimerWorker(object sender, System.Timers.ElapsedEventArgs e)
{
// Code here...
}
全局文件:
void Application_Start(object sender, EventArgs e)
{
Scheduler myScheduler = new Scheduler();
myScheduler.Scheduler_Start();
}