asp.net/C# 后台线程消失的问题
做了一个定时抓天气的线程, 在全局类里启动.
一开始都好,但是不久(几个小时后)天气预报就不见了,线程莫名消失了
请教高手,为什么
线程程序
public WeatherThread()
{
ThreadStart thr_start_func = new ThreadStart(threadProc);
fThread = new Thread(thr_start_func);
fThread.Name = "getWeather";
/* fThread.IsBackground = true;
fThread.Start(); //starting the thread
flag = true;
*/
}
public void trigger()
{
if (fThread.IsAlive)
{
fThread.Abort();
}
else
{
fThread.IsBackground = true;
fThread.Start();
}
}
public static void threadProc()
{
while (true)
{
try
{
getRSS();
Thread.Sleep(timeinternal * 1000);
}
catch (Exception)
{
}
}
}
}
启动部分:global.asax
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
WeatherThread Wt = new WeatherThread();
Wt.trigger();
}