如果我:
app_offline.html
当前运行的线程(在所有三种情况下)包括后台线程会发生什么?它们是否都被立即终止,或者正在运行的是否允许完成?
由于
安德鲁
答案 0 :(得分:7)
通过添加 app_offline.htm ,应用程序发送Application_End
并在此函数返回后,程序的其余线程将被终止。在池设置中设置等待Application_End
返回的最长时间。
如果停止完整池,则此池下的所有站点都遵循相同的过程。如果您只打开app_offline.htm,则只会影响此站点。
要避免线程因此关闭而终止,请在Application_End
void Application_End(object sender, EventArgs e)
{
// This is a custom function that you must make and
// check your threads in the program
MyTheadClass.WaitForAllMyThreadsToExist();
// after this function exit the rest of the threads are killed.
}
您等待Application_End以使线程退出等待状态(可能是互斥锁)时,该站点不再接受Web连接,似乎没有响应。因此,当您收到此消息时,您可以尽快退出线程。
答案 1 :(得分:0)
放置app_offline.html时:
根据ScottGu的this文章,它说应用程序域已卸载。并且基于this文章,当卸载app域并抛出ThreadAbortException时,所有后台线程都会停止。
我不确定是否停止了网站,但停止应用程序池应具有相同的效果。
答案 2 :(得分:0)
注意文件名必须是app_offline.htm。使用app_offline.html无效!