<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-7577421612120825312.post3269481978144047279..comments</id><updated>2010-02-26T19:25:21.727Z</updated><category term='Personal'/><category term='&quot;M&quot;'/><category term='Windows 8'/><category term='.Net'/><category term='Math'/><category term='Windows'/><category term='PDC 2009'/><category term='XNA'/><category term='HymnSheet'/><category term='VSTO'/><category term='Book Reviews'/><category term='OData'/><category term='Fiddler'/><category term='Links'/><category term='Software'/><category term='Project Euler'/><category term='Windows Azure'/><category term='WP7Comp'/><category term='LINQ'/><category term='PDC 2008'/><category term='Build Windows'/><category term='UIAutomation'/><category term='REST'/><category term='How to'/><category term='Jobs'/><category term='PDC 2010'/><category term='WP7'/><category term='COM'/><category term='Humour'/><category term='Algorithms'/><category term='C# 5'/><category term='Freelancing'/><category term='Blogging'/><category term='C#'/><category term='WinRT'/><category term='Competition'/><category term='Seaturtle Software'/><category term='WCF'/><category term='Functional Programming'/><category term='Agile'/><category term='Bugs'/><category term='SQL Server Modelling'/><category term='NHibernate'/><category term='Protocol Buffers'/><category term='VB.Net'/><category term='Recipes'/><category term='ASP.Net'/><category term='Training'/><category term='WPF'/><category term='Silverlight'/><category term='Direct UI'/><category term='Excel'/><category term='C# 4.0'/><title type='text'>Comments on Functional Fun: Cancelling Long-running LINQ queries</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.functionalfun.net/feeds/3269481978144047279/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html'/><author><name>Sam</name><uri>http://www.blogger.com/profile/01345100698738870730</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Blokl_3SWiA/TLnxX6u-kVI/AAAAAAAAAxM/4G8IFTrvgGc/S220/Portrait+Cropped.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-5430690959482170838</id><published>2010-02-26T19:25:21.727Z</published><updated>2010-02-26T19:25:21.727Z</updated><title type='text'>What did you get as an answer for that 4-digit pro...</title><content type='html'>What did you get as an answer for that 4-digit product palindrome?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/5430690959482170838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/5430690959482170838'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1267212321727#c5430690959482170838' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-736569299'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-8864972826924303321</id><published>2009-08-26T14:18:39.736+01:00</published><updated>2009-08-26T14:18:39.736+01:00</updated><title type='text'>@Anonymous:
Glad I could help</title><content type='html'>@Anonymous:&lt;br /&gt;Glad I could help</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/8864972826924303321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/8864972826924303321'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1251292719736#c8864972826924303321' title=''/><author><name>Sam</name><uri>http://www.blogger.com/profile/01345100698738870730</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Blokl_3SWiA/SLw1U2t3fnI/AAAAAAAAAQk/5eLgmX4so5E/S220/MyPicture.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-104150628'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-4788013489840474557</id><published>2009-08-26T02:17:01.325+01:00</published><updated>2009-08-26T02:17:01.325+01:00</updated><title type='text'>This is brilliant. Thanks for sharing.

I&amp;#39;m us...</title><content type='html'>This is brilliant. Thanks for sharing.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m using this to cancel Linq to SQL queries without any problems so far. There are some limitations, but for the most part they do not matter:&lt;br /&gt;&lt;br /&gt;1. call to AsCancelable must be the last thing in the pipeline so instead of putting it right after first from, you should put it after select, ie.&lt;br /&gt;var query = from row in dc.table where... select ...;&lt;br /&gt;var query = query.AsCancelable(...);&lt;br /&gt;&lt;br /&gt;This allows runtime  to push your query to SQLServer as if this was just another ordinary query.&lt;br /&gt;&lt;br /&gt;2. Of course, you won&amp;#39;t be able to cancel query at database level, but you can stop fetching rows, which is what I actually neaded.&lt;br /&gt;&lt;br /&gt;3. Unfortunately this means you can&amp;#39;t use stuf like Max, First, etc. in any usefull way. If you put it before AsCancelable, you&amp;#39;ll only get one record so there&amp;#39;s no need to cancel anything, and if you put it after, it will be evaluated at client, which is probably not what you intended.&lt;br /&gt;&lt;br /&gt;Aside from this I don&amp;#39;t see any obvious problems.&lt;br /&gt;&lt;br /&gt;Also, if you want to use it to query SQL, it makes sense to declare it as&lt;br /&gt;public static IEnumerable(T) AsCancelable(T)(this IQueryable(T) sequence...)&lt;br /&gt;This way you can say&lt;br /&gt;long itemCount = sequence.Count();&lt;br /&gt;right there in the extension method itself and save yourself the trouble of doing it manually, and sending it in as a parameter every time you use it. Count will be executed at database and it won&amp;#39;t enumerate collection in the process.&lt;br /&gt;&lt;br /&gt;Thanks again for pointing me in the right direction. This was bogging me down for some time now.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/4788013489840474557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/4788013489840474557'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1251249421325#c4788013489840474557' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1926890628'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-1892147470948348119</id><published>2008-10-09T09:22:00.000+01:00</published><updated>2008-10-09T09:22:00.000+01:00</updated><title type='text'>Cancelling a Linq to SQL query is much more diffic...</title><content type='html'>Cancelling a Linq to SQL query is much more difficult, I'm afraid. I don't really have any answers. &lt;BR/&gt;&lt;BR/&gt;My best suggestion is to run the query on a separate thread so that you can abandon it, if needs be. You might not be able to do this in all circumstances though, because I think the DataContext is tied to a specific thread.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/1892147470948348119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/1892147470948348119'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1223540520000#c1892147470948348119' title=''/><author><name>Sam</name><uri>http://www.blogger.com/profile/01345100698738870730</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Blokl_3SWiA/SLw1U2t3fnI/AAAAAAAAAQk/5eLgmX4so5E/S220/MyPicture.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-104150628'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-563909112420946208</id><published>2008-10-08T22:40:00.000+01:00</published><updated>2008-10-08T22:40:00.000+01:00</updated><title type='text'>how to cancel a linq to sql execution?</title><content type='html'>how to cancel a linq to sql execution?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/563909112420946208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/563909112420946208'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1223502000000#c563909112420946208' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-759382415'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-917513930544071776</id><published>2008-07-15T08:58:00.000+01:00</published><updated>2008-07-15T08:58:00.000+01:00</updated><title type='text'>BW,&lt;br&gt;  You can certainly use TakeWhile to suppor...</title><content type='html'>BW,&lt;BR/&gt;  You can certainly use TakeWhile to support cancellation, but it wouldn't give you the progress reporting as well.&lt;BR/&gt;&lt;BR/&gt;Sam</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/917513930544071776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/917513930544071776'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1216108680000#c917513930544071776' title=''/><author><name>Sam</name><uri>http://www.blogger.com/profile/01345100698738870730</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-104150628'/></entry><entry><id>tag:blogger.com,1999:blog-7577421612120825312.post-3140911190772072342</id><published>2008-07-14T02:44:00.000+01:00</published><updated>2008-07-14T02:44:00.000+01:00</updated><title type='text'>Couldn't you just as easily use TakeWhile for this...</title><content type='html'>Couldn't you just as easily use TakeWhile for this task?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/3140911190772072342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7577421612120825312/3269481978144047279/comments/default/3140911190772072342'/><link rel='alternate' type='text/html' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html?showComment=1215999840000#c3140911190772072342' title=''/><author><name>BW</name><uri>http://www.blogger.com/profile/17683471955431290697</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.functionalfun.net/2008/07/cancelling-long-running-linq-queries.html' ref='tag:blogger.com,1999:blog-7577421612120825312.post-3269481978144047279' source='http://www.blogger.com/feeds/7577421612120825312/posts/default/3269481978144047279' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2015111379'/></entry></feed>
