<?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 : server side async query</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : server side async query</description>
  <pubDate>Thu, 14 May 2026 11:46:58 -700</pubDate>
  <lastBuildDate>Fri, 15 Nov 2013 07:37:52 -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=4522</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>server side async query :  I tested it, it seems to works....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17233#17233</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 15-Nov-2013 at 7:37am<br /><br />I tested it, it seems to works. Thanks.<div><br></div><div>Also about the microsoft BCL packages, since I have upgraded to SignalR v2 I have this warning on all my projets.</div><div><br></div><div><i>Warning 6<span ="apple-tab-span"="" style="white-space: pre;">	</span>The predefined type 'System.Runtime.CompilerServices.IAsyncStateMachine' is defined in multiple assemblies in the global alias, using the definition of&nbsp;'c:\Dev\Project\packages\Microsoft.CompilerServices.AsyncTargetingPack.1.0.0\lib\sl50\Microsoft.CompilerServices.AsyncTargetingPack.Silverlight5.dll'<span ="apple-tab-span"="" style="white-space: pre;">	</span>C:\Dev\Project\Harness\Global.Harness.SL\CSC<span ="apple-tab-span"="" style="white-space: pre;">	</span>Global.Harness.tn.SL</i></div><div><br></div><div><span style="line-height: 1.4;">I m looking forward to the upgrade.</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;">Regards</span></div><span style="font-size:10px"><br /><br />Edited by kdev - 15-Nov-2013 at 7:38am</span>]]>
   </description>
   <pubDate>Fri, 15 Nov 2013 07:37:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17233#17233</guid>
  </item> 
  <item>
   <title>server side async query : Although you can turn off the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17179#17179</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> 4522<br /><strong>Posted:</strong> 30-Oct-2013 at 4:25pm<br /><br />Although you can turn off the EntityManager's thread affinity by setting the AuthorizedThreadId to null, the problem in a free-threaded environment is that task continuations will also run on worker threads, and these threads can execute concurrently.&nbsp;&nbsp; Internally in DevForce, when an async query completes a synchronous merge into the EM cache is performed, and it's here where you're seeing the problem, as these merges are all running concurrently on different threads.&nbsp; The EM isn't designed to be thread safe, so eventually you will see these random exceptions.<DIV sab="1667">&nbsp;</DIV><DIV sab="1668">To work around this behavior you can provide your own single-threaded SynchronizationContext, a working sample of which you can find at &nbsp;<a href="http://blogs.msdn.com/b/pfxteam/archive/2012/01/20/10259049.aspx" target="_blank">http://blogs.msdn.com/b/pfxteam/archive/2012/01/20/10259049.aspx</A>.&nbsp; We use something like this within our test suite, which is also free threaded, when we need to ensure that async actions are synchronized to a thread.</DIV>]]>
   </description>
   <pubDate>Wed, 30 Oct 2013 16:25:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17179#17179</guid>
  </item> 
  <item>
   <title>server side async query : ok thank you </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17173#17173</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 30-Oct-2013 at 8:51am<br /><br />ok thank you]]>
   </description>
   <pubDate>Wed, 30 Oct 2013 08:51:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17173#17173</guid>
  </item> 
  <item>
   <title>server side async query : Sorry, we&amp;#039;re still looking...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17172#17172</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> 4522<br /><strong>Posted:</strong> 30-Oct-2013 at 8:50am<br /><br />Sorry, we're still looking at this and don't have a fix or workaround yet.]]>
   </description>
   <pubDate>Wed, 30 Oct 2013 08:50:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17172#17172</guid>
  </item> 
  <item>
   <title>server side async query : Hi,any idea ? </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17170#17170</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 30-Oct-2013 at 4:26am<br /><br />Hi,<div><br></div><div>any idea ?</div>]]>
   </description>
   <pubDate>Wed, 30 Oct 2013 04:26:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17170#17170</guid>
  </item> 
  <item>
   <title>server side async query :      ** Edited **Hi,I have...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17158#17158</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 25-Oct-2013 at 8:12am<br /><br /><div><b>** Edited **</b></div><div><br></div><div>Hi,</div><div><br></div><div><div>I have a LOT of problems using async query methods on the server.</div><div>I get random exception or strange behavior while having 4 queries in // awaited in a Task.WhenAll.</div><div><br></div><div><br></div><div>so far I got in my main application those random Exception (can happen once every 10 or more exceutions) while awaiting Task.WhenAll() :</div><div>- "Execution of query against the server was successful but execution of query against the local cache failed"</div><div>- "Object reference not set to an instance of an object"</div><div>- another one about the collection changed during an enumeration</div><div><br></div><div>I also have a query returning 0 entity while it should ALWAYS return 1 entity (query part of the WhenAll).</div><div><span style="line-height: 1.4;">If I execute the exact same query right after the WhenAll but withouth the Async method (standard ToList()), the query return the expected entity !!</span></div><div>As for the exception above, <i><b>this is a random behavior</b></i>.</div><div><br></div><div><br></div><div>I tried an exemple on NorthWindDB, here is the code (<a href="http://www.ideablade.com/forum/uploads/1623/ServerExecuteAsync.zip" target="_blank">uploads/1623/ServerExecuteAsync.zip</a>)<span style="line-height: 1.4;">&nbsp;:</span></div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>&nbsp; &nbsp; private static async void TestMothodWithAsync()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var em = new NorthwindIBEntities();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; em.AuthorizedThreadId = null;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (var bcl = 1; bcl &lt;= 1000; bcl++)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; em.Clear();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Iteration {0}", bcl);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tskOrder = new EntityQuery&lt;Order&gt;().With(em).ExecuteAsync();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tskRegion = new EntityQuery&lt;Region&gt;().With(em).ExecuteAsync();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tskCategory = new EntityQuery&lt;Category&gt;().With(em).ExecuteAsync();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tskTerritory = new EntityQuery&lt;Territory&gt;().With(em).ExecuteAsync();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; await Task.WhenAll(tskOrder, tskRegion, tskCategory, tskTerritory);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Done.");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.ReadLine();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div></pre></td></tr></table></div><div><br></div><div>When I execute the console application, it will throw an Exception "Object reference not set to an instance of an object" on a random iteration (can be at iteration 1 or as late as at iteration 200).</div><div>Note : I didn't get the others kind of exception in the test project.</div><div><br></div><div><br></div><div><b>Am I doing something wrong ?</b></div><div><br></div><div><span style="line-height: 1.4;">Below the trace of the Exception :</span></div><div><br></div><div><font face="Courier New, Courier, mono">System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.&lt;FireQueuedEvents&gt;b__f9(Action a)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Collections.Generic.List`1.ForEach(Action`1 action)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.FireQueuedEvents()</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.LoadingBlock.Dispose()</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityQueryResultCollection..ctor(DataQueryResultCollection dqResults, EntityManager entityManager, MergeStrategy mergeStrategy)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.MergeAndReturnUsingCache(IEntityFinder finder, DataQueryResultCollection dqResults)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.ProcessFetchedData(DataQueryResultCollection dqResults, IEntityFinder finder)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.&lt;ExecuteFetchAsync&gt;d__c1.MoveNext()</font></div><div><font face="Courier New, Courier, mono">--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.GetResult()</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityQueryFinder.&lt;ExecuteAsync&gt;d__0.MoveNext()</font></div><div><font face="Courier New, Courier, mono">--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.GetResult()</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à IdeaBlade.EntityModel.EntityManager.&lt;ExecuteQueryAsyncCore&gt;d__69.MoveNext()</font></div><div><font face="Courier New, Courier, mono">--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</font></div><div><font face="Courier New, Courier, mono">&nbsp; &nbsp;à System.Runtime.CompilerServices.TaskAwaiter.GetResult()</font></div></div><div><font face="Courier New, Courier, mono"><br></font></div><div><font face="Courier New, Courier, mono"><br></font></div><div><br></div><span style="font-size:10px"><br /><br />Edited by kdev - 25-Oct-2013 at 8:29am</span>]]>
   </description>
   <pubDate>Fri, 25 Oct 2013 08:12:48 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17158#17158</guid>
  </item> 
  <item>
   <title>server side async query : ok thanks for the info.note :...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17154#17154</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 24-Oct-2013 at 9:59am<br /><br />ok thanks for the info.<div><br></div><div><br></div><div>note : I just noticed that the IProgress&lt;T&gt; and Tuple&lt;T1,T2..&gt; implementation are not in the BCL Async package as I thought but in the BCL Portability pack.</div><div><br></div>]]>
   </description>
   <pubDate>Thu, 24 Oct 2013 09:59:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17154#17154</guid>
  </item> 
  <item>
   <title>server side async query : I don&amp;#039;t have an ETA but I...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17153#17153</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> 4522<br /><strong>Posted:</strong> 24-Oct-2013 at 9:49am<br /><br /><P>I don't have an ETA but I can tell you that it won't be included in the upcoming 7.2.2 release.&nbsp; </P><DIV>The new package adds several assemblies and is about 10x larger than the targeting pack, so we've been holding off on this until we saw a demand.&nbsp; We'll see about including this in a release before year end.</DIV>]]>
   </description>
   <pubDate>Thu, 24 Oct 2013 09:49:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17153#17153</guid>
  </item> 
  <item>
   <title>server side async query :   Originally posted by kimjDevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17152#17152</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 24-Oct-2013 at 9:23am<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by kimj</strong></em><br /><br /><span style="line-height: 1.4;">&nbsp;DevForce uses version 1 of the "Async Targeting Pack for Visual Studio 11" to provide async support to Silverlight applications.&nbsp; This pack has actually been deprecated in favor of the Microsoft.Bcl.Async package, but we haven't made this upgrade yet.</span><span style="line-height: 1.4;">&nbsp;</span><span style="line-height: 1.4;"><br></span></td></tr></table><div><br></div><div>Have you an ETA on the switch to&nbsp;<span style="line-height: 1.4;">Microsoft.Bcl.Async ? I'd like to benefits of the IProgress&lt;T&gt; which is, as far as I know, &nbsp;only available on this package for SL.</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;">regards</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;"><br></span></div>]]>
   </description>
   <pubDate>Thu, 24 Oct 2013 09:23:55 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17152#17152</guid>
  </item> 
  <item>
   <title>server side async query : thank you </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17126#17126</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 11-Oct-2013 at 7:44am<br /><br />thank you]]>
   </description>
   <pubDate>Fri, 11 Oct 2013 07:44:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17126#17126</guid>
  </item> 
  <item>
   <title>server side async query : You can use async methods on the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17122#17122</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> 4522<br /><strong>Posted:</strong> 10-Oct-2013 at 10:24am<br /><br />You can use async methods on the server.&nbsp; The AuthorizedThreadId is used within some EntityManager calls in an awkward attempt to detect multi-threaded use of the EM.&nbsp; In free threaded environments it's not expected that an async call will return to the original calling thread, and you can safely disable the check by setting AuthorizedThreadId to null.<DIV>&nbsp;</DIV><DIV>Regarding use of ConfigureAwait(false) in Silverlight, this looks like a bug in the Async Targeting Pack.&nbsp; DevForce uses version 1 of the "Async Targeting Pack for Visual Studio 11" to provide async support to Silverlight applications.&nbsp; This pack has actually been deprecated in favor of the Microsoft.Bcl.Async package, but we haven't made this upgrade yet.</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 10 Oct 2013 10:24:18 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17122#17122</guid>
  </item> 
  <item>
   <title>server side async query :  Hi,Since Devforce allow to asynchronous...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17083#17083</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4522<br /><strong>Posted:</strong> 10-Oct-2013 at 3:14am<br /><br /><div>Hi,</div><div><br></div><div>Since Devforce allow to asynchronous query the database from the client or the server, I want to use them on the server to optimize my work.</div><div><br></div><div>When you await a Task on the server you doesn't always come back to the original thread. When that happens the EntityManager throw an exception on the next query because it doesn't run on the original thread.</div><div>The solution is to set AuthorizedThreadId to null to allow to use the EntityManager from any thead but the documentation also say the EntityManager isn't thread safe.</div><div><br></div><div>So I am a bit confused with the "not thread safe" and the possibility to run the query on a different thread.</div><div><br></div><div>In which scenario (with AuthorizedThreadId = null) should I avoid using Async methods on the server ?&nbsp;</div><div>Is running many query on the same EM in the same time (task.whenAll) while a few might be on a different thread is one of them ?</div><div>Is using the Async method on the server not recommended ?</div><div><br></div><div>Also, is using ConfigureAwait(false) on a query Silverlight not recommended ?</div><div><br></div><div><span style="line-height: 1.4;">Regards,</span></div><div><br></div><span style="font-size:10px"><br /><br />Edited by kdev - 10-Oct-2013 at 4:40am</span>]]>
   </description>
   <pubDate>Thu, 10 Oct 2013 03:14:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4522&amp;PID=17083#17083</guid>
  </item> 
 </channel>
</rss>