如何app_offline.htm,停止一个IIS网站和停止的应用程序池影响当前正在运行的线程? [英] How does app_offline.htm, stopping an IIS Site and Stopping an App Pool affect currently running threads?

查看:127
本文介绍了如何app_offline.htm,停止一个IIS网站和停止的应用程序池影响当前正在运行的线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我:


  • 把一个 app_offline.html 在网站根目录

  • 停止IIS 7.5的网站

  • 停止IIS 7.5应用程序池

  • put an app_offline.html in the website root
  • stop an IIS 7.5 site
  • stop an IIS 7.5 App Pool

会发生什么,以当前正在运行的线程(在所有三种情况下),包括后台线程?难道他们都立即终止,或者运行允许完成的?

What happens to currently running threads (in all three cases) including background threads? Are they all immediately terminated, or are running ones allowed to finish?

感谢

安德鲁

推荐答案

通过添加 app_offline.htm 应用程序发送 Application_End 之后这个函数返回程序的线程其余被杀害。等待的最长时间 Application_End 返回设置在池设置。

By adding the app_offline.htm the application send the Application_End and after this function return the rest of the threads of the program are killed. The maximum time of wait for the Application_End to return is set on the pool settings.

如果您停止整个池,那么所有这池下遵循同样的程序的网站。如果你只打开app_offline.htm那么只有这个网站受到影响。

If you stop the full pool then all the sites that under this pool follow the same procedure. If you only open the app_offline.htm then only this site affected.

要避免你的线程本关机杀,上设置一个等待状态 Application_End

To avoid your threads to kill by this shutdown, set a wait state on the 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等待你的线程退出(mutex的可能)的网站没有再接受网络连接,好像不响应的时间。因此,它给你让你的线程,当你收到此消息,尽快退出。

One more note.

All the time that you wait on Application_End for your threads to exit from the wait state (of a mutex probably) the site is not longer accept web connections and it seems like not responding. So its up to you to make your threads exit as soon as possible when you get this message.

这篇关于如何app_offline.htm,停止一个IIS网站和停止的应用程序池影响当前正在运行的线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆