<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Long running method</title>
	<atom:link href="http://benreichelt.net/blog/2005/07/21/long-running-method/feed/" rel="self" type="application/rss+xml" />
	<link>http://benreichelt.net/blog/2005/07/21/long-running-method/</link>
	<description></description>
	<lastBuildDate>Tue, 18 Aug 2009 22:20:45 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Anonymous</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-418</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 31 Jul 2005 22:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-418</guid>
		<description>It was taking 50 seconds to connect to MySql 4.1.x from my windows 2003 machine, heres what fixed it.</description>
		<content:encoded><![CDATA[<p>It was taking 50 seconds to connect to MySql 4.1.x from my windows 2003 machine, heres what fixed it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: breichelt</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-417</link>
		<dc:creator>breichelt</dc:creator>
		<pubDate>Sun, 24 Jul 2005 08:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-417</guid>
		<description>So, I found the problem, the issue was that I was calling into an api that used the HttpContext.Current, not just the Request object that I was passing in, and by the time came to call HttpContext.Current, I was getting a NullReferenceException thrown because there was no HttpContext, like Scott mentioned.

However, I fixed the problem by discovering why the method was taking a long time (6 minutes) in the first place, but I&#039;ll post that as another entry.  But now I dont need to run the method asynchronously, so its a non issue, thanks for the suggestions.</description>
		<content:encoded><![CDATA[<p>So, I found the problem, the issue was that I was calling into an api that used the HttpContext.Current, not just the Request object that I was passing in, and by the time came to call HttpContext.Current, I was getting a NullReferenceException thrown because there was no HttpContext, like Scott mentioned.</p>
<p>However, I fixed the problem by discovering why the method was taking a long time (6 minutes) in the first place, but I&#8217;ll post that as another entry.  But now I dont need to run the method asynchronously, so its a non issue, thanks for the suggestions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: btompkins</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-416</link>
		<dc:creator>btompkins</dc:creator>
		<pubDate>Fri, 22 Jul 2005 08:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-416</guid>
		<description>I am actually just getting into this this week... have you read this?  It&#039;s an oldie, but goodie.

http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx?print=true</description>
		<content:encoded><![CDATA[<p>I am actually just getting into this this week&#8230; have you read this?  It&#8217;s an oldie, but goodie.</p>
<p><a href="http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx?print=true" rel="nofollow">http://msdn.microsoft.com/msdnmag/issues/03/06/Threading/default.aspx?print=true</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: breichelt</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-415</link>
		<dc:creator>breichelt</dc:creator>
		<pubDate>Fri, 22 Jul 2005 07:58:14 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-415</guid>
		<description>Geoff, I also tried explicitly creating a new thread, but I got the same result. I think Scott is correct in his assertion, so I&#039;m going to try Thomas&#039;s suggestion, its a pain in the to grab everything that I want from the Request, but such is life.......</description>
		<content:encoded><![CDATA[<p>Geoff, I also tried explicitly creating a new thread, but I got the same result. I think Scott is correct in his assertion, so I&#8217;m going to try Thomas&#8217;s suggestion, its a pain in the to grab everything that I want from the Request, but such is life&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-414</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 22 Jul 2005 06:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-414</guid>
		<description>I think the safest approach would be to extract everything you need from the request and pass the extracted data to the thing you add to the thread pool.

I believe there is always a risk that the request will end before you access it.</description>
		<content:encoded><![CDATA[<p>I think the safest approach would be to extract everything you need from the request and pass the extracted data to the thing you add to the thread pool.</p>
<p>I believe there is always a risk that the request will end before you access it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-413</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 21 Jul 2005 22:47:17 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-413</guid>
		<description>Geoff is right. The thread inside of Page_Load will queue the work item for processing, then run off and finish rendering the page.

When the ASP.NET runtime sees the request has finished processing, then all bets are off on any state related to the request. That includes Request, Response, and any other property on HttpContext.</description>
		<content:encoded><![CDATA[<p>Geoff is right. The thread inside of Page_Load will queue the work item for processing, then run off and finish rendering the page.</p>
<p>When the ASP.NET runtime sees the request has finished processing, then all bets are off on any state related to the request. That includes Request, Response, and any other property on HttpContext.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gappleby</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-412</link>
		<dc:creator>gappleby</dc:creator>
		<pubDate>Thu, 21 Jul 2005 21:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-412</guid>
		<description>I&#039;d say what&#039;s happening is that the queued workitem never gets a chance to run before the page is finished and has been unloaded.

Without trying it out, I can&#039;t say for sure what&#039;s going on, but as a quick test, try explicitly creating a new thread and kicking it off, instead of adding it to the threadpool. There&#039;s more liklihood that the thread will at least start up before your page finishes.

If it _does_ start up, then you at least know why this method fails, if not the right way to do it :)</description>
		<content:encoded><![CDATA[<p>I&#8217;d say what&#8217;s happening is that the queued workitem never gets a chance to run before the page is finished and has been unloaded.</p>
<p>Without trying it out, I can&#8217;t say for sure what&#8217;s going on, but as a quick test, try explicitly creating a new thread and kicking it off, instead of adding it to the threadpool. There&#8217;s more liklihood that the thread will at least start up before your page finishes.</p>
<p>If it _does_ start up, then you at least know why this method fails, if not the right way to do it <img src='http://benreichelt.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: breichelt</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-411</link>
		<dc:creator>breichelt</dc:creator>
		<pubDate>Thu, 21 Jul 2005 20:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-411</guid>
		<description>Kirk, this is just some sample code, the actual code had other stuff in it that I removed for clarity and brevity, the other code was irrelevant.</description>
		<content:encoded><![CDATA[<p>Kirk, this is just some sample code, the actual code had other stuff in it that I removed for clarity and brevity, the other code was irrelevant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://benreichelt.net/blog/2005/07/21/long-running-method/comment-page-1/#comment-410</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 21 Jul 2005 19:22:54 +0000</pubDate>
		<guid isPermaLink="false">http://s194721765.onlinehome.us/blog/2005/07/21/long-running-method/#comment-410</guid>
		<description>not sure if this affects anything, but you&#039;d probably want to wrap that code inside a &quot;if (!Page.IsPostback) {...}&quot; block, so you can guarantee it&#039;s only executed the first time.</description>
		<content:encoded><![CDATA[<p>not sure if this affects anything, but you&#8217;d probably want to wrap that code inside a &#8220;if (!Page.IsPostback) {&#8230;}&#8221; block, so you can guarantee it&#8217;s only executed the first time.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

