且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当我重新启动在AppDomain前台线程没有举起应用

更新时间:2022-05-30 22:23:35

请,注意单词应用程序,在声明中应用程序不能终止,直到所有的前台线程已终止。在回收的情况下,应用程序不会终止。在回收ASP.NET正在卸载旧应用程序域和加载新的。一切都在一个进程中完成的。过程没有结束。在卸载的AppDomain范围,所有线程(背景和前景)被杀害。
因此,ASP.NET不会等待前台线程回收过程中完成。
尝试创造在其Main方法前台线程简单的控制台应用程序。它会工作,直到线程终止。

Please, pay attention to the word "application" in statement "application can't terminate until all of its foreground threads have terminated". In case of recycling, application is not terminated. During recycling ASP.NET is unloading old AppDomain and loading new one. Everything is done inside single process. Process isn't terminated. In scope of AppDomain unloading, all threads (Background and Foreground) are killed. So, ASP.NET won't wait for foreground threads to complete during recycling. Try simple console application which creates a Foreground thread in its Main method. It will work until the thread is terminated.