<?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 : Cross thread exception... where &#039;s my problem?</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Cross thread exception... where &#039;s my problem?</description>
  <pubDate>Wed, 13 May 2026 13:59:51 -700</pubDate>
  <lastBuildDate>Wed, 23 Nov 2011 00:02:05 -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=3106</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>Cross thread exception... where &#039;s my problem? :   Hello,for @Denisk : I&amp;#039;m...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12100#12100</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1136" rel="nofollow">pponzano</a><br /><strong>Subject:</strong> 3106<br /><strong>Posted:</strong> 23-Nov-2011 at 12:02am<br /><br />Hello,<div>for @Denisk : I'm not sure that Telerik reporting handle correcly an async result..I've to try... the problem for me is due to the fact I generate the Repository on the client (WPF) and when I ask for the report the rendering report starts itself a new thread...so passing the IRepository in the report costructor is not a good thing... maybe I can create a new manager each time the report is created (since the reports are in read-only there's no risk that two manager reading at the same time will damage something)...</div><div>for @mgood (I'm advapi of <a href="http://devforcecaliburn.codeplex.com/" target="_blank">http://devforcecaliburn.codeplex.com/</a>&nbsp;so you've just helped me a lot!,thanks) if I decorate with &#091;PartCreationPolicy(CreationPolicy.NonShared)&#093; is ok or it's just a workaround? what's the cons of this?</div><div>&nbsp;</div><div>Thanks</div><div>Paolo</div>]]>
   </description>
   <pubDate>Wed, 23 Nov 2011 00:02:05 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12100#12100</guid>
  </item> 
  <item>
   <title>Cross thread exception... where &#039;s my problem? :   @pponzano,If you are not explicilty...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12098#12098</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3106<br /><strong>Posted:</strong> 22-Nov-2011 at 9:36pm<br /><br />@pponzano,<div>If you are not explicilty starting a new thread on the client yourself, then the Telerick ReportViewer is indeed doing it's work on a different thread. If that's the case, then you should obtain a new instance of the repository before calling GetSecuritiesNoteForReport. Then this new repository instance will create the EntityManager on the correct thread. </div><div>&nbsp;</div><div>Decorate your repository with &#091;PartCreationPolicy(CreationPolicy.NonShared)&#093;, then IoC.GetInstance(typeof(IApplicationRepository), null) will return a new instance every time.</div><div>&nbsp;</div><div>Marcel</div>]]>
   </description>
   <pubDate>Tue, 22 Nov 2011 21:36:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12098#12098</guid>
  </item> 
  <item>
   <title>Cross thread exception... where &#039;s my problem? : Unless, of course, you&amp;#039;re...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12097#12097</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3106<br /><strong>Posted:</strong> 22-Nov-2011 at 7:14pm<br /><br />Unless, of course, you're actually working on the server, in which case you are perfectly correct in doing synchronous.<div><br></div><div>If this is the case, then you need to make sure that your EntityManager is not being used by multiple concurrent threads. If somehow the EntityManager was created on another thread, you can set the AuthorizedThreadId to 0 to turn off the check. However, only do this if you're absolutely sure you're not doing concurrent access.</div><div><br></div><div>Another suggestion is to make sure that you create an EntityManager for each server side request.</div>]]>
   </description>
   <pubDate>Tue, 22 Nov 2011 19:14:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12097#12097</guid>
  </item> 
  <item>
   <title>Cross thread exception... where &#039;s my problem? : Hi pponzano;I&amp;#039;m not too familiar...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12096#12096</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3106<br /><strong>Posted:</strong> 22-Nov-2011 at 6:28pm<br /><br />Hi pponzano;<div><br></div><div>I'm not too familiar with Telerik control but by looking at the exception message, it seems that your synchronous query inside GetSecuritiesNoteforReport is causing the problem.</div><div><br></div><div>As suggested by the message, you might need to restructure that method to use asynchronous query.</div>]]>
   </description>
   <pubDate>Tue, 22 Nov 2011 18:28:51 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12096#12096</guid>
  </item> 
  <item>
   <title>Cross thread exception... where &#039;s my problem? : Hello,I&amp;#039;m relatively new...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12093#12093</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1136" rel="nofollow">pponzano</a><br /><strong>Subject:</strong> 3106<br /><strong>Posted:</strong> 22-Nov-2011 at 8:50am<br /><br />Hello,<br>I'm relatively new to DevForce IdeaBlade / Application Framework...<br>as far I've done some testing everything was ok... I load a single view, done my stuff, close and reopened project and everything was ok... now that I've started opening a new page things get damaged...<br><br>I've got a screen defined as <br><br>&nbsp;&nbsp;&nbsp; &#091;Export&#093;<br>&nbsp;&nbsp;&nbsp; public class SecuritiesNoteManagerViewModel : Screen<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;private BindableCollection&lt;SecuritiesNoteResult&gt; _SecuritiesNoteResult = new BindableCollection&lt;SecuritiesNoteResult&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private readonly IApplicationRepository _repository;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private readonly IWindowManager _windowManager;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private DateTime _date;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int _ancheEstinti;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#091;ImportingConstructor&#093;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public SecuritiesNoteManagerViewModel(IApplicationRepository repository, IWindowManager windowManager)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _repository = repository;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _windowManager = windowManager;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>...<br><br>&nbsp;&nbsp; public void OpenSecuritiesNote()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _windowManager.ShowWindow(new ReportViewModel(_repository)); //here troubles start<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>}<br><br>When I click the Button and the OpenSecuritiesNote starts I got an execption inside my Telerik Reporting saying :<br><br><i>An EntityManager can only execute on a single thread. This EntityManager is authorized to execute on the thread with id=’8’; the requested operation came from the thread with Id=‘12’.<br><br>Consider calling the EntityManager’s asynchronous methods; they work safely on background threads managed by DevForce. <br><br>You may have to disable this cross-thread checking for specific reasons such as automated testing. Please review our documentation on multi-threading issues and the EntityManager.AuthorizedThreadId property.<br></i><br><br>The method that raises the exception is :<br><br>&nbsp; public DomainObject GetSecuritiesNoteForReport(int xxx, DateTime data)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var query = Manager.DomainObject .Where(nota =&gt; nota.xxx == xxx&amp;&amp; nota.DATA == data);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var op = query.Execute(); //here<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (op.ToQuery().Count() == 0) return null;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var item = op.ToQuery().FirstOrNullEntity();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return item;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>I use IoC pattern just not to create a new manager... I think that the reportviewer of telerik creates the report on another thread (probably it's so since I use the domain model on a server, not in the WPF client)<br><br>Thanks<br><br><br><br>]]>
   </description>
   <pubDate>Tue, 22 Nov 2011 08:50:41 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3106&amp;PID=12093#12093</guid>
  </item> 
 </channel>
</rss>