<?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: How can I run 2 QueryFeaturesAsync in parallel ? in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218459#M11388</link>
    <description>&lt;P&gt;Apologies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried your code and it appear to work fine: control returns to the UI thread and the async tasks continue to run effectively in the background. For the query I'm using 1=1 which retrieves all features which appear to be about 100 per layer. Note it took almost 1min from submitting the query to the service responding so I do think the server/service appears to be running a little slowly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string MAPSERVER_SA4 = "https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0";
string MAPSERVER_SA3 = "https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/1";
ServiceFeatureTable sft_SA4 = new ServiceFeatureTable (new Uri($"{MAPSERVER_SA4}"));
ServiceFeatureTable sft_SA3 = new ServiceFeatureTable(new Uri($"{MAPSERVER_SA3}"));
QueryParameters myquery = new QueryParameters() { WhereClause="1=1"};
FeatureQueryResult fc1; FeatureQueryResult fc2;

var t1 = sft_SA4.QueryFeaturesAsync(myquery);
var t2 = sft_SA3.QueryFeaturesAsync(myquery);
await Task.WhenAll(t1, t2);    // both complete
fc1 = t1.Result;
fc2 = t1.Result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Oct 2022 23:36:23 GMT</pubDate>
    <dc:creator>MichaelBranscomb</dc:creator>
    <dc:date>2022-10-03T23:36:23Z</dc:date>
    <item>
      <title>How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218123#M11385</link>
      <description>&lt;P&gt;Having just discovered ServiceFeatureTable I am now converting my code to use them. I have an opportunity to execute 2 queries in parallel, but I can't work out how to do it.&lt;/P&gt;&lt;P&gt;Code fragment 1 shows my Serial code. It works correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        Dim sft_SA4 As New ServiceFeatureTable(New Uri($"{MAPSERVER_SA4}"))
        Dim sft_SA3 As New ServiceFeatureTable(New Uri($"{MAPSERVER_SA3}"))
        Dim myquery As New QueryParameters
        Dim fc1 As FeatureQueryResult, fc2 As FeatureQueryResult

        fc1 = Await sft_SA4.QueryFeaturesAsync(myquery).ConfigureAwait(False)
        fc2 = Await sft_SA3.QueryFeaturesAsync(myquery).ConfigureAwait(False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code fragment 2 shows my attempt to run both these queries in parallel. It compiles, but when run it just hangs at the WhenAll statement&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Dim sft_SA4 As New ServiceFeatureTable(New Uri($"{MAPSERVER_SA4}"))
Dim sft_SA3 As New ServiceFeatureTable(New Uri($"{MAPSERVER_SA3}"))
Dim myquery As New QueryParameters
Dim fc1 As FeatureQueryResult, fc2 As FeatureQueryResult
Dim t1 = sft_SA4.QueryFeaturesAsync(myquery)
Dim t2 = sft_SA3.QueryFeaturesAsync(myquery)
Await Task.WhenAll(t1, t2)      ' both complete
fc1 = t1.Result
fc2 = t1.result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;What have I done wrong? (myquery is populated elsewhere, but left out for clarity)&lt;/P&gt;</description>
      <pubDate>Sun, 02 Oct 2022 10:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218123#M11385</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2022-10-02T10:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218330#M11386</link>
      <description>&lt;P&gt;Because you're awaiting the task, the second query will be executed after the first one completes. To execute the tasks in parallel see&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.whenall?view=net-6.0" target="_blank"&gt;Task.WhenAll Method (System.Threading.Tasks) | Microsoft Learn&lt;/A&gt;&amp;nbsp;or &lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.parallel.foreach?view=net-7.0" target="_blank"&gt;Parallel.ForEach Method (System.Threading.Tasks) | Microsoft Learn&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you're migrating to use the more data-oriented end points - we now recommend using&amp;nbsp;&lt;A title="Class ServiceGeodatabase" href="https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Data.ServiceGeodatabase.html" target="_blank" rel="noopener"&gt;Class ServiceGeodatabase&lt;/A&gt;&amp;nbsp;rather than the more granular ServiceFeatureTable because your FeatureServer and therefore the client ServiceGeodatabase may contain behavior that operates on multiple tables in the service.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some background info:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Attribute rules:&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/release-notes/prior-releases/release-notes-for-100-14/#support-for-attribute-rules" target="_blank"&gt;Release notes for 100.14 | ArcGIS Runtime API for .NET | ArcGIS Developers&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Feature service client edits:&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/release-notes/prior-releases/release-notes-for-100-13/#geodatabase" target="_blank"&gt;Release notes for 100.13 | ArcGIS Runtime API for .NET | ArcGIS Developers&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Branch versioning:&amp;nbsp;&lt;A href="https://developers.arcgis.com/net/release-notes/prior-releases/release-notes-for-100-10/#branch-versioned-utility-network" target="_blank"&gt;Release notes for 100.10 | ArcGIS Runtime API for .NET | ArcGIS Developers&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 16:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218330#M11386</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2022-10-03T16:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218450#M11387</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3014"&gt;@MichaelBranscomb&lt;/a&gt;, but you seem to be only looking at the first fragment of code. I recognised it was serial. The second fragment of my code is my attempt to do these in parallel. I am using WhenAll to await completion of both. It doesn't work, and I seek guidance as to what I have done wrong.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 23:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218450#M11387</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2022-10-03T23:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218459#M11388</link>
      <description>&lt;P&gt;Apologies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried your code and it appear to work fine: control returns to the UI thread and the async tasks continue to run effectively in the background. For the query I'm using 1=1 which retrieves all features which appear to be about 100 per layer. Note it took almost 1min from submitting the query to the service responding so I do think the server/service appears to be running a little slowly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string MAPSERVER_SA4 = "https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0";
string MAPSERVER_SA3 = "https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/1";
ServiceFeatureTable sft_SA4 = new ServiceFeatureTable (new Uri($"{MAPSERVER_SA4}"));
ServiceFeatureTable sft_SA3 = new ServiceFeatureTable(new Uri($"{MAPSERVER_SA3}"));
QueryParameters myquery = new QueryParameters() { WhereClause="1=1"};
FeatureQueryResult fc1; FeatureQueryResult fc2;

var t1 = sft_SA4.QueryFeaturesAsync(myquery);
var t2 = sft_SA3.QueryFeaturesAsync(myquery);
await Task.WhenAll(t1, t2);    // both complete
fc1 = t1.Result;
fc2 = t1.Result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 23:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218459#M11388</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2022-10-03T23:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218465#M11389</link>
      <description>&lt;P&gt;Wow - 1 minute for queries in parallel ! After about 30s I bailed out assuming it had 'hung'. When I profile the serial case, I get 1003 mS. I have no idea why the parallel case takes so much longer, but I think I'll stick with the serial method.&lt;BR /&gt;&lt;BR /&gt;I have just realised that myquery selects a single feature, whilst yours selects them all. Even so, my single feature query is too slow (in parallel) to be useable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Dim t = Stopwatch.StartNew
fc1 = Await sft_SA4.QueryFeaturesAsync(myquery).ConfigureAwait(False)
fc2 = Await sft_SA3.QueryFeaturesAsync(myquery).ConfigureAwait(False)
t.Stop()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 00:05:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218465#M11389</guid>
      <dc:creator>MarcHillman</dc:creator>
      <dc:date>2022-10-04T00:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I run 2 QueryFeaturesAsync in parallel ?</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218480#M11390</link>
      <description>&lt;P&gt;You might try testing the service via the HTML pages as well, to help track down where the bottleneck is e.g. the query below uses 1=1 to get all 108 features from your service, including geometry. If you don't need the geometry you can disable that part of the query - in the API you'd specify&amp;nbsp;ReturnGeometry = false.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0/query?where=1=1&amp;amp;text=&amp;amp;objectIds=&amp;amp;time=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;distance=&amp;amp;units=esriSRUnit_Foot&amp;amp;relationParam=&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;returnTrueCurves=false&amp;amp;maxAllowableOffset=&amp;amp;geometryPrecision=&amp;amp;outSR=&amp;amp;havingClause=&amp;amp;returnIdsOnly=false&amp;amp;returnCountOnly=false&amp;amp;orderByFields=&amp;amp;groupByFieldsForStatistics=&amp;amp;outStatistics=&amp;amp;returnZ=false&amp;amp;returnM=false&amp;amp;gdbVersion=&amp;amp;historicMoment=&amp;amp;returnDistinctValues=false&amp;amp;resultOffset=&amp;amp;resultRecordCount=&amp;amp;returnExtentOnly=false&amp;amp;datumTransformation=&amp;amp;parameterValues=&amp;amp;rangeValues=&amp;amp;quantizationParameters=&amp;amp;featureEncoding=esriDefault&amp;amp;f=html" target="_blank"&gt;https://geo.abs.gov.au/arcgis/rest/services/ASGS2021/SA4/MapServer/0/query?where=1=1&amp;amp;text=&amp;amp;objectIds=&amp;amp;time=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;distance=&amp;amp;units=esriSRUnit_Foot&amp;amp;relationParam=&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;returnTrueCurves=false&amp;amp;maxAllowableOffset=&amp;amp;geometryPrecision=&amp;amp;outSR=&amp;amp;havingClause=&amp;amp;returnIdsOnly=false&amp;amp;returnCountOnly=false&amp;amp;orderByFields=&amp;amp;groupByFieldsForStatistics=&amp;amp;outStatistics=&amp;amp;returnZ=false&amp;amp;returnM=false&amp;amp;gdbVersion=&amp;amp;historicMoment=&amp;amp;returnDistinctValues=false&amp;amp;resultOffset=&amp;amp;resultRecordCount=&amp;amp;returnExtentOnly=false&amp;amp;datumTransformation=&amp;amp;parameterValues=&amp;amp;rangeValues=&amp;amp;quantizationParameters=&amp;amp;featureEncoding=esriDefault&amp;amp;f=html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 01:29:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-can-i-run-2-queryfeaturesasync-in-parallel/m-p/1218480#M11390</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2022-10-04T01:29:58Z</dc:date>
    </item>
  </channel>
</rss>

