<?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 : Why GetEnitiesAsync does not behave consistently for me?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Why GetEnitiesAsync does not behave consistently for me?</description>
  <pubDate>Thu, 11 Jun 2026 00:02:39 -700</pubDate>
  <lastBuildDate>Wed, 09 Jul 2008 14:38:45 -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=885</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>Why GetEnitiesAsync does not behave consistently for me? : Ok, I think I will take the simplest...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3212#3212</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 2:38pm<br /><br />Ok, I think I will take the simplest one PM per session solution for now. Thanks for your information!]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 14:38:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3212#3212</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : No, there&amp;#039;s no set limit...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3211#3211</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> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 2:28pm<br /><br />No, there's no set limit on the number of created / connected / logged in PMs.]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 14:28:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3211#3211</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : If create a PM per request or...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3210#3210</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 2:24pm<br /><br />If create a PM per request or per session, it there a limit on the number of PMs that can be opened concurrently? ]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 14:24:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3210#3210</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : There is some initialization overhead...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3209#3209</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> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 2:13pm<br /><br />There is some initialization overhead when constructing a PM, especially the first time when some statics are created, but in order to ensure reliable results it may be your best alternative.&nbsp;&nbsp; Connect() logic is quite fast if you are not using a BOS, and even if you are using a BOS, Connect() calls after the first are usually fast.&nbsp; Login() logic may actually be a bit slower, esp. if you've implemented a LoginManager, and a Login is always implicitly done when needed prior to any fetch. <DIV>&nbsp;</DIV><DIV>In our web service implementation support we create (and discard) a PM per request and haven't&nbsp;seen any issues.&nbsp; You can also store the PM in Session scope.</DIV><DIV>&nbsp;</DIV><DIV>If you wrap the PM in order to make your own async calls, I think I would use&nbsp;the synchronous GetEntities call and allow the worker thread to block until completion.&nbsp; You would need to provide your own locking to synchronize access to the PM.&nbsp; Another option would be to use a "main" PM &nbsp;and&nbsp;one or more&nbsp;"worker" PMs, and then use ImportEntities to merge results into the main PM.</DIV>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 14:13:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3209#3209</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : Kimj, So, one way is to not sharing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3208#3208</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 1:06pm<br /><br /><P>Kimj,</P><P>So, one way is to not sharing the PM and make synchronous calls to it. I implemented that as my first attempt. But when I saw the nature of my request processes had a large number and short life, I started to worry about the efficiency of creating new PMs every time. I am not sure how heavy the PM object is, and how intensive it is to connect and disconnect. With your internal knowledge, would you recommend using it that way?</P><P>Another way is to create a wrapper around the PM, let’s call it MyPM. MyPM should have a delegate called MyGet. MyGet can be called asynchronously from the asynchronous pages. But what I do inside this function? Call your GetEnities synchronously? I will need to implement locking to prevent the concurrency. This would be a bottleneck. Call you GetEntitiesAsync? I still need to block myself to wait for the result, which is also bottleneck. </P><P>Maybe I also need to implement MyGet as a asynchronous call and implement a MyGetComplete event. I implemented this idea once. I also got the same exception I stated earlier. Maybe I didn’t implement it&nbsp;completely right. Within DevForce or your customers, has anybody else encountered the same issue? <BR></P>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 13:06:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3208#3208</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : GetEntitiesAsync is more a means...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3207#3207</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> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 12:09pm<br /><br /><P>GetEntitiesAsync is more a means of making non-blocking data requests than of sharing a PM.&nbsp; When GetEntitiesAsync returns it always tries to merge its results into the PM cache, and requires that this merge occur on the same thread that made the request (and presumably the same thread that created the PM).&nbsp; The PM cache does not intrinsically support any type of multi-threaded access - either read or write.&nbsp; </P><DIV>I'm not an ASP.NET person, but based on the article I'd say that async pages cannot be used with GetEntitiesAsync calls.&nbsp; GetEntitiesAsync also uses the thread pool when it goes async, which also sounds less desirable here too.&nbsp; You might be able to create a delegate for the GetEntities method you're using, and call BeginInvoke and EndInvoke on that.&nbsp; This would bypass our checks, but if you synchronize access to the PM when necessary it may work.</DIV><DIV>&nbsp;</DIV><DIV>I'll see if our ASP.NET guy can provide any more insight</DIV>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 12:09:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3207#3207</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : Kimj, I understand that PersistenceManager...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3206#3206</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 11:16am<br /><br />Kimj, <BR>&nbsp;<BR>I understand that PersistenceManager is not thread safe. That’s why I am calling GetEnititiesAsync. From reading the DevForce document “Multi-Threading in a DevForce App”, I get the impression that GetEntitiesAsync is the answer to share a PM in multi-threaded environment.<DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 11:16:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3206#3206</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : Aha, I see the problem. The WebForm...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3205#3205</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 11:03am<br /><br />Aha, I see the problem. The WebForm page that I am using to call the GetEntitiesAsyn is an asynchronous page. According the Microsoft document (<a href="http://msdn.microsoft.com/en-us/magazine/cc163725.aspx" target="_blank">http://msdn.microsoft.com/en-us/magazine/cc163725.aspx</A>) this page will be attached to different threads before and after the call to the asynchronous external function. This is the only reason that I can think of why your library sees two different thread ID.&nbsp; If this is the case, it means GetEnitiesAsyn is not suitable for the asynchronous page then?]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 11:03:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3205#3205</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : That error is thrown after checking...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3203#3203</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> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 9:28am<br /><br />That error is thrown after checking the thread ID of both the originating request and the post-processing thread - they are expected to be the same (meaning post-processing is occurring in the same SynchronizationContext as the request).&nbsp; <DIV>&nbsp;</DIV><DIV>The PersistenceManager itself is not threadsafe, so my guess is the fact that you're sharing a single PM in Application scope is what's causing the inconsistent results.</DIV>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 09:28:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3203#3203</guid>
  </item> 
  <item>
   <title>Why GetEnitiesAsync does not behave consistently for me? : I am building a web that uses...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3202#3202</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=352" rel="nofollow">johnxjcheng</a><br /><strong>Subject:</strong> 885<br /><strong>Posted:</strong> 09-Jul-2008 at 8:19am<br /><br /><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>I am building a web that uses IB layer to access a database. Most user requests involve reading data from db. So, I created a single instance of PM at the application start up and let each request thread to call the GetEnitiesAsync on this PM. All the code worked. I got the data. And the data displayed on the web pages correctly. But the whole process is erratic. Very often the GetEntitiesCompleted returns no data. And the Error property of GetEntitiesCompletedEventArgs shows this error:</FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>"xxxAsync methods can only be called from applications running in a SynchronizationContext that supports thread synchronization. This means, in general, applications running in a WinForms or ASP.NET environment.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Console or WindowsService applications must use BeginInvoke and EndInvoke mechanisms instead"</FONT></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><o:p><FONT face="Times New Roman" size=3>&nbsp;</FONT></o:p></P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>The call is from a WebForm. The application is created with VS 2008. I also verified that SynchronizationContext.Current is not null on the calling thread. So, why is the underneath call behaviour inconsistent?</FONT></P>]]>
   </description>
   <pubDate>Wed, 09 Jul 2008 08:19:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=885&amp;PID=3202#3202</guid>
  </item> 
 </channel>
</rss>