<?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 Re: Feature layer crashing on query complete in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501979#M2541</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the pointers, that has helped me a bit. I added some logging of the dispatcher threads. Something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;QueryTask queryTask = new QueryTask(url);
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args)
{
&amp;nbsp; FeatureSet featureSet = args.FeatureSet;
&amp;nbsp; if (featureSet.Features.Count &amp;gt; 0)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add results to the map.
&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (Graphic resultFeature in featureSet.Features)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logger.DebugFormat("LayoutRoot: Dispatcher.Thread: {0}, {1}", LayoutRoot.Dispatcher.Thread.ManagedThreadId, LayoutRoot.Dispatcher.Thread.Name);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logger.DebugFormat("resultFeature: Dispatcher.Thread: {0}, {1}", resultFeature.Dispatcher.Thread.ManagedThreadId, resultFeature.Dispatcher.Thread.Name);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultFeature.Symbol = LayoutRoot.Resources["FinalFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... CRASH ...
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the log I can now see that LayoutRoot (an element in the current UserControl) has thread=1 whereas resultFeature (the ArcGIS QueryTask result) has thread=4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That explains the crash ... but now I need to figure out how ArcGIS Runtime can create WPF UI features on the wrong thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I am required to somehow copy these features to new features on the right thread? I don't think so - especially because ArcGIS own FeatureLayers crashes in the same way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/Jørn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:01:52 GMT</pubDate>
    <dc:creator>JornWildt</dc:creator>
    <dc:date>2021-12-11T22:01:52Z</dc:date>
    <item>
      <title>Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501974#M2536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my WPF application I have an ArcGIS map with a set of various feature layers. When I execute the program on my local developer machine it works fine. Unfortunately, once it is deployed on a customer machine, it crashes with the stack trace below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What happens seems to be that one of the internal ArcGIS event handlers are executed from a background thread and tries to access/modify a graphics layer, which in turns touches WPF ... and then, bang, we get a "System.InvalidOperationException: 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;The stack trace doesn't have a single trace from my program - it all happens internally in the ArcGIS WPF components.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone help with an idea of what is going wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 2013-12-02 13:00:53,988 125226ms&amp;nbsp; [Main] App&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; WriteLog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Catching Unhandled exception&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---&amp;gt; System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Threading.Dispatcher.VerifyAccess()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.DependencyObject.GetValue(DependencyProperty dp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicsLayer.&amp;lt;Graphics_Collectionchange d&amp;gt;b__1(Graphic a)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicsLayer.Graphics_Collectionchange d(Object sender, NotifyCollectionchange dEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionchange d(NotifyCollectionchange dEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicCollection.AddRange(IEnumerable`1 items)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.FeatureLayer.task_QueryComplete(Object sender, QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.OnExecuteCompleted(QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.&amp;lt;&amp;gt;c__DisplayClassf.&amp;lt;ExecuteAsync&amp;gt;b__d(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.TaskBase.&amp;lt;&amp;gt;c__DisplayClassc`1.&amp;lt;HandeEventBasedTask&amp;gt;b__a(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task`1.&amp;lt;&amp;gt;c__DisplayClass17.&amp;lt;ContinueWith&amp;gt;b__16(Object obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.InnerInvoke()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.Execute()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; --- End of inner exception stack trace ---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.TaskExceptionHolder.Finalize()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;---&amp;gt; (Inner Exception #0) System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Threading.Dispatcher.VerifyAccess()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.DependencyObject.GetValue(DependencyProperty dp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicsLayer.&amp;lt;Graphics_Collectionchange d&amp;gt;b__1(Graphic a)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicsLayer.Graphics_Collectionchange d(Object sender, NotifyCollectionchange dEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionchange d(NotifyCollectionchange dEventArgs e)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.GraphicCollection.AddRange(IEnumerable`1 items)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.FeatureLayer.task_QueryComplete(Object sender, QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.OnExecuteCompleted(QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.&amp;lt;&amp;gt;c__DisplayClassf.&amp;lt;ExecuteAsync&amp;gt;b__d(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.TaskBase.&amp;lt;&amp;gt;c__DisplayClassc`1.&amp;lt;HandeEventBasedTask&amp;gt;b__a(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task`1.&amp;lt;&amp;gt;c__DisplayClass17.&amp;lt;ContinueWith&amp;gt;b__16(Object obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.InnerInvoke()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.Execute()&amp;lt;---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, Jørn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 11:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501974#M2536</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2013-12-04T11:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501975#M2537</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;Are you able to put together a small reproducer app which demonstrates the issue? (are the feature services publicly accessible / or the Map Packages shareable?)&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, 05 Dec 2013 07:52:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501975#M2537</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2013-12-05T07:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501976#M2538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, but, no I have no small example or public service. Right now I am investigating whether its one machine which is bad or if it happens on all customer machines. I will get back if I find some pattern.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 05:28:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501976#M2538</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2013-12-09T05:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501977#M2539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have now removed my feature layers and then it works - but that's rather silly of course since I need the feature layers. But then I got to my own code which also handles QueryTasks complete - and now it fails there instead with the same kind of error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The stack trace is slightly different but the exception is the same:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 2013-12-19 16:14:56,775 72613ms&amp;nbsp; [Main] App&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; WriteLog&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Catching Unhandled exception&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---&amp;gt; System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Threading.Dispatcher.VerifyAccess()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.DependencyObject.GetValue(DependencyProperty dp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Graphic.get_Layer()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Graphic.set_Symbol(Symbol value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at CBrain.F2.ArcGIS.Client.UserControls.ArcGISMapViewer.QueryTask_ExecuteCompleted(Object sender, QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.OnExecuteCompleted(QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.&amp;lt;&amp;gt;c__DisplayClassf.&amp;lt;ExecuteAsync&amp;gt;b__d(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.TaskBase.&amp;lt;&amp;gt;c__DisplayClassc`1.&amp;lt;HandeEventBasedTask&amp;gt;b__a(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task`1.&amp;lt;&amp;gt;c__DisplayClass17.&amp;lt;ContinueWith&amp;gt;b__16(Object obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.InnerInvoke()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.Execute()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; --- End of inner exception stack trace ---&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.TaskExceptionHolder.Finalize()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;---&amp;gt; (Inner Exception #0) System.InvalidOperationException: The calling thread cannot access this object because a different thread owns it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.Threading.Dispatcher.VerifyAccess()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Windows.DependencyObject.GetValue(DependencyProperty dp)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Graphic.get_Layer()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Graphic.set_Symbol(Symbol value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at CBrain.F2.ArcGIS.Client.UserControls.ArcGISMapViewer.QueryTask_ExecuteCompleted(Object sender, QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.OnExecuteCompleted(QueryEventArgs args)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.QueryTask.&amp;lt;&amp;gt;c__DisplayClassf.&amp;lt;ExecuteAsync&amp;gt;b__d(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.TaskBase.&amp;lt;&amp;gt;c__DisplayClassc`1.&amp;lt;HandeEventBasedTask&amp;gt;b__a(Task`1 result)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task`1.&amp;lt;&amp;gt;c__DisplayClass17.&amp;lt;ContinueWith&amp;gt;b__16(Object obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.InnerInvoke()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at System.Threading.Tasks.Task.Execute()&amp;lt;---&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The very strange part here is that the code called by OnExecuteCompleted runs on the main thread - both on my developer machine (where I can debug the program) as well as on the customer machine where I log the thread ID in "ArcGISMapViewer.QueryTask_ExecuteCompleted".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How on earth can I get "The calling thread cannot access this object because a different thread owns it." when accessing the WPF UI elements from the *main* thread? And only on the customer machine, not my own .... Heeeeelp ....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/Jørn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2013 13:49:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501977#M2539</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2013-12-19T13:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501978#M2540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think that what you really want to know is which thread owns the object.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That might be something like control.Dispatcher.Thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This link tells you how to check if your thread is the owner and how to dispatch the call to the correct thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://stackoverflow.com/questions/9732709/the-calling-thread-cannot-access-this-object-because-a-different-thread-owns-it"&gt;http://stackoverflow.com/questions/9732709/the-calling-thread-cannot-access-this-object-because-a-different-thread-owns-it&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Dec 2013 15:05:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501978#M2540</guid>
      <dc:creator>RichardWatson</dc:creator>
      <dc:date>2013-12-19T15:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501979#M2541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the pointers, that has helped me a bit. I added some logging of the dispatcher threads. Something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;QueryTask queryTask = new QueryTask(url);
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;

private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args)
{
&amp;nbsp; FeatureSet featureSet = args.FeatureSet;
&amp;nbsp; if (featureSet.Features.Count &amp;gt; 0)
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add results to the map.
&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (Graphic resultFeature in featureSet.Features)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logger.DebugFormat("LayoutRoot: Dispatcher.Thread: {0}, {1}", LayoutRoot.Dispatcher.Thread.ManagedThreadId, LayoutRoot.Dispatcher.Thread.Name);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Logger.DebugFormat("resultFeature: Dispatcher.Thread: {0}, {1}", resultFeature.Dispatcher.Thread.ManagedThreadId, resultFeature.Dispatcher.Thread.Name);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultFeature.Symbol = LayoutRoot.Resources["FinalFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... CRASH ...
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the log I can now see that LayoutRoot (an element in the current UserControl) has thread=1 whereas resultFeature (the ArcGIS QueryTask result) has thread=4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That explains the crash ... but now I need to figure out how ArcGIS Runtime can create WPF UI features on the wrong thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps I am required to somehow copy these features to new features on the right thread? I don't think so - especially because ArcGIS own FeatureLayers crashes in the same way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/Jørn&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:01:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501979#M2541</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2021-12-11T22:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501980#M2542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That piece of code is BTW a copy of the official sample code: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/wpf/help/index.html#//01n70000001s000000"&gt;http://help.arcgis.com/en/webapi/wpf/help/index.html#//01n70000001s000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 06:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501980#M2542</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2013-12-20T06:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Feature layer crashing on query complete</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501981#M2543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The observations above are based on ArcGIS runtime 10.2 from october 2013.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I tried to recompile with ArcGIS runtime 2.4.0.851 as downloaded from here: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/wpf/"&gt;http://help.arcgis.com/en/webapi/wpf/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;... AND IT WORKS!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So something has been introduced in 10.2 that makes QueryTask construct WPF UI elements on the wrong thread.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Dec 2013 07:30:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/feature-layer-crashing-on-query-complete/m-p/501981#M2543</guid>
      <dc:creator>JornWildt</dc:creator>
      <dc:date>2013-12-20T07:30:25Z</dc:date>
    </item>
  </channel>
</rss>

