Search code examples
c#asynchronousarcgisesri

ArcGis Query Task never returns a result


I'm not certain if I have a problem with the async handling in my code or my use of the ArcGis desktop. I wanted to query a feature layer I had created to see if a facility lay within the feature layer's polygon. I wrote the following code for the query:

        var query = new Query(new Envelope(-180, 0, 0, 90), SpatialRelationship.Within)
        {
            Geometry = new MapPoint((double) facility.Latitude, (double) facility.Longitude)
        };
        query.OutFields.Add("*");
        QueryTask queryTask = new QueryTask(new Uri("http://services3.arcgis.com/eJFBr5VfFl7nBQt4/arcgis/rest/services/Zone_Features/FeatureServer/0"));
        var result = queryTask.ExecuteAsync(query).Result;

When I run through the code, the code never steps past the var result line. I've waited minutes, but it stays there, awaiting the result. Am I missing something?


Solution

  • If you were using ArcGIS Runtime SDK for .NET then you would have to await ExecuteAsync like QueryResult queryResult = await queryTask.ExecuteAsync(query); Have they switched to async model in 10.2?