为什么工作线程使我的ASP.NET生成器在睡眠期间遇到ThreadAbortException?

我在 Windows Server 2008,IIS 7.5上运行的ASP.NET应用程序中生成一个工作线程.这个工作线程做的第一件事就是睡眠N秒,然后它才能真正起作用.在睡眠期间,捕获一个ThreadAbortException.

你能解释一下这种行为,并且你的奖励点指向我可以用来调整行为的任何IIS / ASP.NET设置.

编辑:更多信息.捕获ThreadAbortException的建议帮助我解决了这个问题,谢谢.根据我学到的东西,我完全重写了这个问题的措辞,但同样的问题,为什么这个工作线程在睡眠中会中止?

解决方法

ThreadAbortException发生在你的工作线程上,因为有人在其上调用Thread.Abort,所以它可能与你的工作线程没有直接关系,而是一些外部原因.您应该检查的第一个地方是您自己的代码,您可以执行任何线程管理或中止.否则,对于IIS,这可能是由于工作进程(w3wp.exe)或应用程序池或AppDomain被回收.

回收可能是由于应用程序池的空闲超时设置,定期计划的回收或内存/ cpu使用触发器.这些可通过服务器资源管理器中的IIS配置管理器(在Win 2K8上)或仅运行inetmgr.exe进行配置.根据Tess的博客here,AppDomain回收还有很多其他原因:

  • Machine.Config,Web.Config or Global.asax are modified
  • The bin directory or its contents is modified
  • The number of re-compilations (aspx,ascx or asax) exceeds the limit
    specified by the
    setting in machine.config or
    web.config (by default this is set to
    15)
  • The physical path of the virtual directory is modified
  • The CAS policy is modified
  • The web service is restarted
  • (2.0 only) Application Sub-Directories are deleted

博客文章还提供了有关追踪回收发生原因的信息.对于初学者,尝试查看事件日志(eventvwr.msc)以查看是否有任何详细信息.

您也可以尝试直接调试工作进程.将VS调试器附加到运行代码的w3wp.exe实例,在Thread.Abort上添加断点(您可能需要在调试器选项中启用“.NET Framework源步进”),并查看Abort源自何处使用调用堆栈窗口.这不会告诉你它为什么会发生,但至少你会知道是谁在做这件事.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“WPF...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这...
Some samples are below for ASP.Net web form controls:(from http://www.visualize.uk.com/resources/asp
问题描述: 对于未定义为 System.String 的列,唯一有效的值是(引发异常)。 For columns not defined as System.String, the only vali
最近用到了CalendarExtender,结果不知道为什么发生了错位,如图在Google和百度上找了很久,中文的文章里面似乎只提到了如何本地化(就是显示中文的月份)以及怎么解决被下拉框挡住的问题,谈
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence changed a lot since 1.1. Here is the order: App
静态声明: ' Style="position: relative" AppendDataBoundItems="True"> (无 或 空 或
以下内容是从网络上搜集资料,然后整理而来的。不当之处,请不吝指教。(The following were from network, and edited by myself. Thanks in a
Imports System Imports System.Reflection Namespace DotNetNuke '*********************************
Ok so you have all seen them: “8 million tools for web development”, “5 gagillion tools that if you
以下内容来源于: http://blog.csdn.net/cuike519/archive/2005/09/27/490316.aspx 问:为什么Session在有些机器上偶尔会丢失? 答:可能和
以下文章提到可以用“http://localhost/MyWebApp/WebAdmin.axd”管理站点: ---------------------------------------------
Visual Studio 2005 IDE相关的11个提高开发效率的技巧 英文原创来源于: http://www.chinhdo.com/chinh/blog/20070920/top-11-vis
C#日期格式化 from: http://51xingfu.blog.51cto.com/219185/46222 日期转化一 为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007
from: http://www.nikhilk.net/UpdateControls.aspx Two controls that go along with the UpdatePanel and
Open the report in the Designer. In the ToolBox, select/expand the "Report Items" section.
from: http://drupal.org/node/75844 Do this: find which TinyMCE theme you are using. For the sake of
asp.net中给用户控件添加自定义事件 用户控件中定义好代理和事件: public delegate void ItemSavedDelegate(object sender, EventArgs
在Windows版本的Safari中浏览以下的页面。 http://www.asp.net/AJAX/Control-Toolkit/Live/Calendar/Calendar.aspx Calen
http://aspnet.4guysfromrolla.com/articles/021506-1.aspx By Scott Mitchell Introduction When creating