<?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 Threading Errors in ArcGISLocalDynamicMapServiceLayer in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389056#M1937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I write a rather simple version that follows the example, these load into my map fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try to create these in a com control, I get an InvalidOperationException from the Dependency Object being invoked in the wrong thread.&amp;nbsp;&amp;nbsp;&amp;nbsp; Of course, it's way down in the bowels of the service diddling the Url:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt; WindowsBase.dll!System.Windows.Threading.Dispatcher.VerifyAccess() + 0x4a bytes 
&amp;nbsp; WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x15 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.dll!ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.Url.set(string value) + 0x2b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.ArcGISLocalDynamicMapServiceLayer.CompleteServiceInitialize(ESRI.ArcGIS.Client.Local.LocalMapService service) + 0xba bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.GetServiceAsyncInternal.AnonymousMethod__0(object s, System.ComponentModel.AsyncCompletedEventArgs e) + 0x4b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalService.OnStartCompleted() + 0x76 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.UpdateMapServicePropertiesCompleteStart.AnonymousMethod__c(ESRI.ArcGIS.Client.Local.LayersInfo layersInfo, ESRI.ArcGIS.Client.Local.Internal.RequestInfo requestInfo2) + 0x48b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.ProcessResponse&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo&amp;gt;(string url, string queryParameters, System.Exception err, bool cancelled, string result, System.Action&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo,ESRI.ArcGIS.Client.Local.Internal.RequestInfo&amp;gt; callback) + 0x2d0 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.Start&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo&amp;gt;.AnonymousMethod__3(object s, System.Net.DownloadStringCompletedEventArgs e) + 0x186 bytes 
&amp;nbsp; System.dll!System.Net.WebClient.OnDownloadStringCompleted(System.Net.DownloadStringCompletedEventArgs e) + 0x15 bytes 
&amp;nbsp; System.dll!System.Net.WebClient.DownloadStringOperationCompleted(object arg) + 0x2a bytes 
&amp;nbsp; mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 bytes 
&amp;nbsp; mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes 
&amp;nbsp; [Native to Managed Transition] &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried routing the code that does all this to the same thread that the MainWindow (and the ArcGISRuntime.Initialize) is run in and it doesn't help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 May 2013 15:55:58 GMT</pubDate>
    <dc:creator>RonaldNatalie</dc:creator>
    <dc:date>2013-05-01T15:55:58Z</dc:date>
    <item>
      <title>Threading Errors in ArcGISLocalDynamicMapServiceLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389056#M1937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I write a rather simple version that follows the example, these load into my map fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try to create these in a com control, I get an InvalidOperationException from the Dependency Object being invoked in the wrong thread.&amp;nbsp;&amp;nbsp;&amp;nbsp; Of course, it's way down in the bowels of the service diddling the Url:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt; WindowsBase.dll!System.Windows.Threading.Dispatcher.VerifyAccess() + 0x4a bytes 
&amp;nbsp; WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x15 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.dll!ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer.Url.set(string value) + 0x2b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.ArcGISLocalDynamicMapServiceLayer.CompleteServiceInitialize(ESRI.ArcGIS.Client.Local.LocalMapService service) + 0xba bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.GetServiceAsyncInternal.AnonymousMethod__0(object s, System.ComponentModel.AsyncCompletedEventArgs e) + 0x4b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalService.OnStartCompleted() + 0x76 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.LocalMapService.UpdateMapServicePropertiesCompleteStart.AnonymousMethod__c(ESRI.ArcGIS.Client.Local.LayersInfo layersInfo, ESRI.ArcGIS.Client.Local.Internal.RequestInfo requestInfo2) + 0x48b bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.ProcessResponse&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo&amp;gt;(string url, string queryParameters, System.Exception err, bool cancelled, string result, System.Action&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo,ESRI.ArcGIS.Client.Local.Internal.RequestInfo&amp;gt; callback) + 0x2d0 bytes 
&amp;nbsp; ESRI.ArcGIS.Client.Local.dll!ESRI.ArcGIS.Client.Local.Internal.Requests.Start&amp;lt;ESRI.ArcGIS.Client.Local.LayersInfo&amp;gt;.AnonymousMethod__3(object s, System.Net.DownloadStringCompletedEventArgs e) + 0x186 bytes 
&amp;nbsp; System.dll!System.Net.WebClient.OnDownloadStringCompleted(System.Net.DownloadStringCompletedEventArgs e) + 0x15 bytes 
&amp;nbsp; System.dll!System.Net.WebClient.DownloadStringOperationCompleted(object arg) + 0x2a bytes 
&amp;nbsp; mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state) + 0x3e bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x60 bytes 
&amp;nbsp; mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x149 bytes 
&amp;nbsp; mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x5 bytes 
&amp;nbsp; [Native to Managed Transition] &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried routing the code that does all this to the same thread that the MainWindow (and the ArcGISRuntime.Initialize) is run in and it doesn't help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 15:55:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389056#M1937</guid>
      <dc:creator>RonaldNatalie</dc:creator>
      <dc:date>2013-05-01T15:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: Threading Errors in ArcGISLocalDynamicMapServiceLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389057#M1938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you zip up and post your example on this thread? (or email me on &lt;/SPAN&gt;&lt;A href="mailto:mbranscomb@esri.com"&gt;mbranscomb@esri.com&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 09:14:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389057#M1938</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2013-05-02T09:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Threading Errors in ArcGISLocalDynamicMapServiceLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389058#M1939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Can you zip up and post your example on this thread? (or email me on &lt;A href="mailto:mbranscomb@esri.com" rel="nofollow noopener noreferrer" target="_blank"&gt;mbranscomb@esri.com&lt;/A&gt;)&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Mike&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually, you can do this without any special code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Create a New ArcGISWpfApplication with the New Project in Visual Studio.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Turn on one of the commented out map layers in the MainWindow.xaml&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Go to Applicacation.xaml and disable the initial load of the main window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; From a thread other than the main thread create the MainWindow class (in my case it's a COM class).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The whole mainwindow will create properly but goes boom asynchronously early on with the path above.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Amusingly, I can work around this by kluging the service creation/start in my thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_pkg = new ArcGISLocalDynamicMapServiceLayer(map_file_name);
&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; These next three lines are SUPPOSED to be handled automatically.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; However, this works around an internal bug in the ServiceLayer crash where it runs
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; things in the wrong thread when we run out of a com context.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; It doesn't happen if we take care of starting up the service ourselves.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;KLUDGE&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_pkg.Service = new LocalMapService();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_pkg.Service.Path = map_file_name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map_pkg.Service.Start();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;/KLUDGE&amp;gt;

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll see if I can cut out the proprietary stuff and zip up a canned set of programs that does this later today.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Amusingly I've worked around this by forcing the service start in the right thread by inserting these lines before I return from the window creation...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:51:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389058#M1939</guid>
      <dc:creator>RonaldNatalie</dc:creator>
      <dc:date>2021-12-11T17:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Threading Errors in ArcGISLocalDynamicMapServiceLayer</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389059#M1940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having a very similar issue trying to access a LocalTiledLayer in a map that is created on its own thread. Is there a known workaround to prevent this issue? I've tried manually calling the .Initialize() method on the layer but it doesn't seem to have any effect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Threading.Dispatcher.VerifyAccess()
&amp;nbsp;&amp;nbsp; at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Map.get_Layers()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Map.getSpatialReferenceFromLayers()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Map.get_SpatialReference()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.LayerCollection.&amp;lt;getTileLayerEnumerator&amp;gt;d__1.MoveNext()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.LayerCollection.get_HasTiledResources()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.LayerCollection.calculateLevelScheme(Boolean raiseInitialized)
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.LayerCollection.layer_OnInitialized(Object sender, EventArgs args)
&amp;nbsp;&amp;nbsp; at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Layer.OnInitialized(EventArgs e)
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Layer.Initialize()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.TiledLayer.Initialize()
&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.ArcGISLocalTiledLayer.InitCompleted(Object sender, RunWorkerCompletedEventArgs e)
&amp;nbsp;&amp;nbsp; at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
&amp;nbsp;&amp;nbsp; at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
&amp;nbsp;&amp;nbsp; at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
&amp;nbsp;&amp;nbsp; at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
&amp;nbsp;&amp;nbsp; at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
&amp;nbsp;&amp;nbsp; at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
&amp;nbsp;&amp;nbsp; at System.Threading.ThreadPoolWorkQueue.Dispatch()
&amp;nbsp;&amp;nbsp; at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As an update: I'm able to instantiate the map and add the tiled layer if I invoke it to the UI thread, however the tiled layer is never initialized, even after a manual call to .Initialize()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;someMap.Dispatcher.Invoke(delegate() {someMap.Layers.Add(tiledLayer); });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:51:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/threading-errors-in/m-p/389059#M1940</guid>
      <dc:creator>AaronHigh</dc:creator>
      <dc:date>2021-12-11T17:51:47Z</dc:date>
    </item>
  </channel>
</rss>

