<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create Layer in different thread in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/create-layer-in-different-thread/m-p/724702#M18570</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a graphics layer that has many Graphics on it. This graphics may change depending on clients selection. Since it takes some time to recreate the graphics and add them to the layer, I thought it would be nice to just recreate the layer in a different thread, return it in the WorkItem of the thread that did the work and replace it in the map. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try to add the new layer to the Map though I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The calling thread cannot access this object because a different thread owns it&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To try to solve this problem, I used the dispatcher of the Map like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

map1.Dispatcher.Invoke((Action)
 (()=&amp;gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; map1.Layers.Add(layerCreatedInOtherThread);
 })
 );

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I got the same error. I also tried BeginInvoke and got the same result... So, basically the map cannot use that layer created in a different thread. How can I do this? Any suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Oct 2013 20:01:41 GMT</pubDate>
    <dc:creator>LuisGarcia2</dc:creator>
    <dc:date>2013-10-11T20:01:41Z</dc:date>
    <item>
      <title>Create Layer in different thread</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/create-layer-in-different-thread/m-p/724702#M18570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a graphics layer that has many Graphics on it. This graphics may change depending on clients selection. Since it takes some time to recreate the graphics and add them to the layer, I thought it would be nice to just recreate the layer in a different thread, return it in the WorkItem of the thread that did the work and replace it in the map. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I try to add the new layer to the Map though I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The calling thread cannot access this object because a different thread owns it&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To try to solve this problem, I used the dispatcher of the Map like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;

map1.Dispatcher.Invoke((Action)
 (()=&amp;gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; map1.Layers.Add(layerCreatedInOtherThread);
 })
 );

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And I got the same error. I also tried BeginInvoke and got the same result... So, basically the map cannot use that layer created in a different thread. How can I do this? Any suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Oct 2013 20:01:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/create-layer-in-different-thread/m-p/724702#M18570</guid>
      <dc:creator>LuisGarcia2</dc:creator>
      <dc:date>2013-10-11T20:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer in different thread</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/create-layer-in-different-thread/m-p/724703#M18571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Anyone has any idea on this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Oct 2013 13:26:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/create-layer-in-different-thread/m-p/724703#M18571</guid>
      <dc:creator>LuisGarcia2</dc:creator>
      <dc:date>2013-10-18T13:26:07Z</dc:date>
    </item>
  </channel>
</rss>

