<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : AddAsyncQuery Question</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : AddAsyncQuery Question</description>
  <pubDate>Sun, 12 Apr 2026 02:28:56 -700</pubDate>
  <lastBuildDate>Thu, 30 Jul 2009 06:45:19 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1391</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>AddAsyncQuery Question : That fixed it!  Thanks! </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5072#5072</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 30-Jul-2009 at 6:45am<br /><br />That fixed it!  Thanks!  ]]>
   </description>
   <pubDate>Thu, 30 Jul 2009 06:45:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5072#5072</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : Ah, it&amp;#039;s a problem with closures...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5067#5067</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 29-Jul-2009 at 4:36pm<br /><br />Ah, it's a problem with closures within the loop adding the tasks.&nbsp; Use this instead&nbsp;- <DIV><table width="99%"><tr><td><pre class="BBcode"></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var item in queries) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>IEntityQuery query = item;</strong><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task.AddAsyncAction&lt;EntityFetchedEventArgs&gt;(i,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (args, callback) =&gt; _defaultManager.ExecuteQueryAsync(<strong>query</strong>, callback, null),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; null);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></pre></td></tr></table></DIV>]]>
   </description>
   <pubDate>Wed, 29 Jul 2009 16:36:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5067#5067</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : Thanks.  I&amp;#039;ve stepped through...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5057#5057</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 29-Jul-2009 at 1:06pm<br /><br />Thanks.  I've stepped through it now and it does not seem to be erroring anywhere.  The completionmap is showing all 6 queries executed and completed with no errors.  I have added errorhandlers to the tasks.  Nothing seems to be failing, however, when I use this syntax, the cached entities are available:<br /><table width="99%"><tr><td><pre class="BBcode">public static void InitializeCacheAsync(AsyncCompletedCallback&lt;AsyncEventArgs&gt; serialCallback, Action&lt;AsyncParallelTaskCompletedArgs&gt; completionAction)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var task = AsyncParallelTask.Create();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddExceptionHandler(InitializationExceptionHandler);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddInitializationQueries(task);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.Execute(serialCallback, completionAction);<br />}<br /><br />private static void AddInitializationQueries(AsyncParallelTask&lt;object&gt; task)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(1, x =&gt; _defaultManager.AccountingMonths);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(2, x =&gt; _defaultManager.DealTypes);<br />}</pre></td></tr></table><br /><br />When I execute this code, the entities are not available:<br /><table width="99%"><tr><td><pre class="BBcode">public static void InitializeCacheAsync(AsyncCompletedCallback&lt;AsyncEventArgs&gt; serialCallback, Action&lt;AsyncParallelTaskCompletedArgs&gt; completionAction)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var task = AsyncParallelTask.Create();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddExceptionHandler(InitializationExceptionHandler);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddInitializationQueries(task);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.Execute(serialCallback, completionAction);<br />}<br /><br />private static void AddInitializationQueries(AsyncParallelTask&lt;object&gt; task)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queries = GetInitializationQueries();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int i = 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach (var item in queries)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//task.AddAsyncQuery(i, x =&gt; item);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncAction&lt;EntityFetchedEventArgs&gt;(i,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(args, callback) =&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_defaultManager.ExecuteQueryAsync(item, callback, null),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;null);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />private static IList&lt;IEntityQuery&gt; GetInitializationQueries()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queries = new List&lt;IEntityQuery&gt;();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queries.Add(_defaultManager.AccountingMonths);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queries.Add(_defaultManager.DealTypes);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return queries;<br />}</pre></td></tr></table><br /><br />Is the problem in making creating the list of queries as an IList&lt;IEntityQuery&gt;?  Should it be IList&lt;IUntypedEntityQuery&gt;?]]>
   </description>
   <pubDate>Wed, 29 Jul 2009 13:06:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5057#5057</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : Hmm, I&amp;#039;d check the completion...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5052#5052</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 29-Jul-2009 at 8:33am<br /><br />Hmm, I'd check the completion action on the AsyncParallelTask to see what it contains, since it will have results from all actions in the task.&nbsp; I'd also check that the EntityManager used for all queries&nbsp;is the correct one.&nbsp; Also check to see if an error was caught by your exception handler.&nbsp; And since it's a test method, make sure it's not exiting prematurely.&nbsp; ]]>
   </description>
   <pubDate>Wed, 29 Jul 2009 08:33:53 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5052#5052</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : I&amp;#039;m not getting any errors...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5051#5051</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 29-Jul-2009 at 7:45am<br /><br />I'm not getting any errors with this code, but it does not seem to be loading the entities into the cache.  My unit tests are getting the Null entity instead.  Any suggestions?  Thanks, Simon]]>
   </description>
   <pubDate>Wed, 29 Jul 2009 07:45:34 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5051#5051</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : Yes, there is a workaround. The...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5024#5024</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 24-Jul-2009 at 10:55am<br /><br />Yes, there is a workaround.&nbsp; The extension methods, like AddAsyncQuery, are there to help hide some of the complexities of the syntax, but aren't required.&nbsp; Here's how you can do this using AddAsyncAction instead:<DIV>&nbsp;</DIV><DIV><table width="99%"><tr><td><pre class="BBcode"></DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var item in queries) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; task.AddAsyncAction&lt;EntityFetchedEventArgs&gt;(i,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (args, callback) =&gt; _defaultManager.ExecuteQueryAsync(item, callback, null), <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; null);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i++;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR></pre></td></tr></table></DIV>]]>
   </description>
   <pubDate>Fri, 24 Jul 2009 10:55:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5024#5024</guid>
  </item> 
  <item>
   <title>AddAsyncQuery Question : I have these methods that initialize...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5021#5021</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=308" rel="nofollow">skingaby</a><br /><strong>Subject:</strong> 1391<br /><strong>Posted:</strong> 24-Jul-2009 at 8:01am<br /><br />I have these methods that initialize my server side Entity Manager cache:<br /><table width="99%"><tr><td><pre class="BBcode">private static IList&lt;IEntityQuery&gt; GetInitializationQueries()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queries = new List&lt;IEntityQuery&gt;();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queries.Add(_defaultManager.AccountingMonths);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;queries.Add(_defaultManager.DealTypes);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return queries;<br />}<br />public static void InitializeCache()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queries = GetInitializationQueries();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach (var item in queries)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_defaultManager.ExecuteQuery(item);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />}</pre></td></tr></table><br /><br />I am trying to write an AsyncParallelTask to do the same thing for the client, and I can get this to work:<br /><table width="99%"><tr><td><pre class="BBcode">public static void InitializeCacheAsync(Action&lt;AsyncParallelTaskCompletedArgs&gt; callback)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var task = AsyncParallelTask.Create();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddExceptionHandler(InitializationExceptionHandler);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddInitializationQueries(task);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.Execute(callback);<br />}<br />private static void AddInitializationQueries(AsyncParallelTask&lt;object&gt; task)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(1, x =&gt; _defaultManager.AccountingMonths);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(2, x =&gt; _defaultManager.DealTypes);<br />}</pre></td></tr></table><br /><br />I would like to do this instead:<br /><table width="99%"><tr><td><pre class="BBcode">private static void AddInitializationQueries(AsyncParallelTask&lt;object&gt; task)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var queries = GetInitializationQueries();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int i = 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach (var item in queries)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;task.AddAsyncQuery(i, x =&gt; item);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />}</pre></td></tr></table><br /><br />But the AddAsyncQuery method needs an IEntityQuery&lt;T&gt; but I only have IEntityQuery objects in my collection.  Is there any way to work around this?  Thanks, Simon]]>
   </description>
   <pubDate>Fri, 24 Jul 2009 08:01:51 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1391&amp;PID=5021#5021</guid>
  </item> 
 </channel>
</rss>