![](/img/trans.png)
[英]how to achieve conditional app_offline.htm in asp .net IIS 7
[英]How does app_offline.htm, stopping an IIS Site and Stopping an App Pool affect currently running threads?
如果我:
app_offline.html
放在网站根目录中 当前运行的线程(在所有三种情况下)包括后台线程会发生什么? 它们是否都立即终止,或者正在运行?
谢谢
安德鲁
通过添加app_offline.htm ,应用程序发送Application_End
并在此函数返回后, 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让你的线程退出等待状态(可能是互斥锁),该网站不再接受网络连接,似乎没有响应。 因此,当您收到此消息时,由您决定是否尽快退出线程。
只是注意到文件名必须是app_offline.htm。 使用app_offline.html将无法正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.