<?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: FeatureSet.ToJson() must now be called on the UI thread in 2.3 in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111231#M2770</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, this wasn't intended and we'll have an update in a future release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As a work-around for now, set the Fields property on the FeatureSet, prior to calling the worker thread, and you should be good to go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
FeatureSet fs = new FeatureSet()
{
 Fields = new List&amp;lt;Field&amp;gt;() //or FeatureLayer.LayerInfo.Fields
};
fs.Features.Add(new ESRI.ArcGIS.Client.Graphic() { Attributes = { { "ID", "1" } }, Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(1, 2) });
System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker();
worker.DoWork += (a, b) =&amp;gt;
 {
&amp;nbsp; FeatureSet fs2 = (FeatureSet)b.Argument;
&amp;nbsp; b.Result = fs2.ToJson();
 };
worker.RunWorkerCompleted += (a, b) =&amp;gt;
 {
&amp;nbsp;&amp;nbsp; MessageBox.Show(b.Result.ToString());
 };
worker.RunWorkerAsync(fs);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for the inconvenience this might have caused you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:40:25 GMT</pubDate>
    <dc:creator>dotMorten_esri</dc:creator>
    <dc:date>2021-12-11T06:40:25Z</dc:date>
    <item>
      <title>FeatureSet.ToJson() must now be called on the UI thread in 2.3</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111230#M2769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As of version 2.3 FeatureSet.ToJson() throws an exception if you call it from a background thread. This was not the case in 2.2. Was this an intended change?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&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.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.Tasks.Utils.JSON.ArcGISJsonWriter.GraphicsToFeatureServiceJson(IEnumerable`1 graphics, Boolean normalize, Boolean onlyDirty, List`1 fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.FeatureSet.ToJson(Boolean includeGeometryInJson, Boolean normalize)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; at ESRI.ArcGIS.Client.Tasks.FeatureSet.ToJson()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 00:55:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111230#M2769</guid>
      <dc:creator>RyanCooney</dc:creator>
      <dc:date>2011-12-21T00:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureSet.ToJson() must now be called on the UI thread in 2.3</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111231#M2770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, this wasn't intended and we'll have an update in a future release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As a work-around for now, set the Fields property on the FeatureSet, prior to calling the worker thread, and you should be good to go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
FeatureSet fs = new FeatureSet()
{
 Fields = new List&amp;lt;Field&amp;gt;() //or FeatureLayer.LayerInfo.Fields
};
fs.Features.Add(new ESRI.ArcGIS.Client.Graphic() { Attributes = { { "ID", "1" } }, Geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(1, 2) });
System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker();
worker.DoWork += (a, b) =&amp;gt;
 {
&amp;nbsp; FeatureSet fs2 = (FeatureSet)b.Argument;
&amp;nbsp; b.Result = fs2.ToJson();
 };
worker.RunWorkerCompleted += (a, b) =&amp;gt;
 {
&amp;nbsp;&amp;nbsp; MessageBox.Show(b.Result.ToString());
 };
worker.RunWorkerAsync(fs);
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for the inconvenience this might have caused you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:40:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111231#M2770</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2021-12-11T06:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureSet.ToJson() must now be called on the UI thread in 2.3</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111232#M2771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the quick reply. I've implemented the workaround and it does the trick.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--Ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Dec 2011 20:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/featureset-tojson-must-now-be-called-on-the-ui/m-p/111232#M2771</guid>
      <dc:creator>RyanCooney</dc:creator>
      <dc:date>2011-12-28T20:02:43Z</dc:date>
    </item>
  </channel>
</rss>

