<?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>AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx</link><description>The AppDomain.ProcessExit is not guaranteed to be called. It's pretty resilient and will deal with common things you may cause from low-trust IL (exceptions, out-of-memory, etc), but there are some things (like rude process shutdown), that an inprocess</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1380235</link><pubDate>Fri, 29 Dec 2006 19:28:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1380235</guid><dc:creator>Mike Stall - MSFT</dc:creator><description>&lt;p&gt;Sam - &lt;/p&gt;
&lt;p&gt;I looked at the english (en-us) version of the URL instead of (zh-tw). &lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn2.microsoft.com/en-us/library/system.appdomain.processexit"&gt;http://msdn2.microsoft.com/en-us/library/system.appdomain.processexit&lt;/a&gt;(VS.80).aspx&lt;/p&gt;
&lt;p&gt;I see it says:&lt;/p&gt;
&lt;p&gt;The total execution time of all ProcessExit event handlers is limited, just as the total execution time of all finalizers is limited at process shutdown. The default is three seconds, which can be overridden by an unmanaged host.&lt;/p&gt;
&lt;p&gt;Key sentence there is &amp;quot;which can be overridden by an unmanaged host&amp;quot;, which means using the hosting API (defined in mscoree.idl).&lt;/p&gt;
&lt;p&gt;I'm not sure which hosting API. However, do you really want to rely on the ProcessExit event since it's not reliably called?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1380235" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1378335</link><pubDate>Fri, 29 Dec 2006 06:42:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1378335</guid><dc:creator>sam</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I got another problem on AppDomain.ProcessExit.&lt;/p&gt;
&lt;p&gt;According to msdn,there is only 3 sec limit when ProcessExit.&lt;/p&gt;
&lt;p&gt;ref url&amp;gt;&amp;gt;&lt;a rel="nofollow" target="_new" href="http://msdn2.microsoft.com/zh-tw/library/system.appdomain.processexit"&gt;http://msdn2.microsoft.com/zh-tw/library/system.appdomain.processexit&lt;/a&gt;(VS.80).aspx&lt;/p&gt;
&lt;p&gt;How can we extend the time limit to more than 3 sec?&lt;/p&gt;
&lt;p&gt;thx &lt;/p&gt;
&lt;p&gt;sam&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1378335" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1185916</link><pubDate>Fri, 01 Dec 2006 21:14:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1185916</guid><dc:creator>Mike Stall - MSFT</dc:creator><description>&lt;p&gt;Antosha - you're toally right. A silly mistake on my part. I've corrected it and reverified. Thanks.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1185916" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1182040</link><pubDate>Fri, 01 Dec 2006 12:26:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1182040</guid><dc:creator>Antosha</dc:creator><description>&lt;p&gt;The example is not just contrived; it actually does not prove your point. If you kill the process on Console.ReadLine, the CurrentDomain.ProcessExit is not set *yet*.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1182040" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1160221</link><pubDate>Mon, 27 Nov 2006 19:07:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1160221</guid><dc:creator>Mike Stall - MSFT</dc:creator><description>&lt;p&gt;Anders - You're right that my example is contrived. It's trying to illustrate the limitations of ProcessExit, not find the most efficient way to call Console.WriteLine. Putting the callback at the start would be more natural.&lt;/p&gt;
&lt;p&gt;Alois - thanks for the link.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1160221" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1159979</link><pubDate>Mon, 27 Nov 2006 17:36:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1159979</guid><dc:creator>Alois Kraus</dc:creator><description>&lt;p&gt;Hi Mike,&lt;/p&gt;
&lt;p&gt;more infos about abnormal and cooperatice application shutdown with the CLR can be found here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://geekswithblogs.net/akraus1/archive/2006/10/30/95435.aspx"&gt;http://geekswithblogs.net/akraus1/archive/2006/10/30/95435.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yours,&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Alois Kraus&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1159979" width="1" height="1"&gt;</description></item><item><title>re: AppDomain.ProcessExit is not guaranteed to be called</title><link>http://blogs.msdn.com/b/jmstall/archive/2006/11/26/process-exit-event.aspx#1159325</link><pubDate>Mon, 27 Nov 2006 14:18:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1159325</guid><dc:creator>Anders Dalvander</dc:creator><description>&lt;p&gt;Shouldn't the Main method be something like this instead:&lt;/p&gt;
&lt;p&gt;static void Main(string[] args)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;start&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Console.ReadLine();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;It still doesn't help against kernel32!TerminateProcess, but placing the code at the end of the Main method seems like a strange and cumbersome way to call Console.WriteLine indirectly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1159325" width="1" height="1"&gt;</description></item></channel></rss>