<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Pedram Rezaei's Ramblings : ASP.NET</title><link>http://blogs.msdn.com/pedram/archive/tags/ASP.NET/default.aspx</link><description>Tags: ASP.NET</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>ThreadAbortException and Unmanaged Code</title><link>http://blogs.msdn.com/pedram/archive/2007/10/02/threadabortexception-and-unmanaged-code.aspx</link><pubDate>Tue, 02 Oct 2007 15:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5241644</guid><dc:creator>pedramr</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pedram/comments/5241644.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pedram/commentrss.aspx?PostID=5241644</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;As you are probably aware &lt;/FONT&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ty8d3wta.aspx"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;Thread.Abort()&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; raises a ThreadAbortException in the thread on which it is invoked, to begin the process of terminating the thread.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Please note that if Abort is called on a managed thread while it is executing unmanaged code, a ThreadAbortException is not thrown until the thread returns to managed code. That is also true when performing a COM Interop or P-Invoke. However if you have a ServicedComponent, the exception is received by the thread inside the component as expected. For instance if you are in an &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/pedram/archive/2007/10/02/how-the-execution-timeout-is-managed-in-asp-net.aspx"&gt;&lt;FONT face=Calibri color=#0000ff size=3&gt;ASP.NET application and a timeout&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; is occurred (timeout is communicated in terms of a ThreadAbortException) the exception is raised inside the component.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5241644" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pedram/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/pedram/archive/tags/COM/default.aspx">COM</category><category domain="http://blogs.msdn.com/pedram/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/pedram/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item><item><title>How the Execution Timeout is managed in ASP.NET</title><link>http://blogs.msdn.com/pedram/archive/2007/10/02/how-the-execution-timeout-is-managed-in-asp-net.aspx</link><pubDate>Tue, 02 Oct 2007 12:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5240126</guid><dc:creator>pedramr</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/pedram/comments/5240126.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pedram/commentrss.aspx?PostID=5240126</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;As you are probably aware, it is possible to specify the execution timeout of an ASP.NET request through the config file. All you need to do is to set the executionTimeout attribute on the httpRuntime element in either the web.config (for one ASP.NET application) or even the machine.config (to affect all ASP.NET applications):&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;httpRuntime&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: red; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;executionTimeout&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;=&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;"&lt;SPAN style="COLOR: blue"&gt;200&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;According to the &lt;/FONT&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/e1f13641(vs.90).aspx"&gt;&lt;FONT face=Calibri size=3&gt;online documentation&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt; the executionTimeout is a TimeSpan attribute that “specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET”. (BTW, it doesn’t work in debug mode)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The default value for this attribute has been set to 90 seconds in ASP.NET 1.x and was increased to 110 seconds in ASP.NET 2.0.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Internally the timeout is managed by a timer (an instance of a System.Threading.Timer class) which is fired every 15 seconds. &lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Internally ASP.NET uses a Timer (an instance of &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;System.Threading.Timer&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;) to invoke the request cancelation process. This timer is fired once every 15 seconds, so if the executionTimeout is set to 3 seconds, in reality the request can timeout at any time between 3 seconds and 18 seconds.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;When the timer is fired, a thread from the ThreadPool is used to check all the requests. The ones that have timed out are sent a ThreadAbortException by calling Abort on the thread executing the request.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;&lt;FONT face=Calibri size=3&gt;So as per above, the executionTimeout only specifies the minimum duration that the request is guaranteed to be executed. The actual timeout can happen between executionTimeout and executionTimeout + 15 seconds.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5240126" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pedram/archive/tags/ASP.NET/default.aspx">ASP.NET</category></item></channel></rss>