var count = await QueuedTask.Run(() =>
{
QueryFilter qf = new QueryFilter()
{
WhereClause = "Class = 'city'"
};
//Getting the first selected feature layer of the map view
var flyr = (FeatureLayer)MapView.Active.GetSelectedLayers()
.OfType<FeatureLayer>().FirstOrDefault();
using (RowCursor rows = flyr.Search(qf)) //execute
{
//Looping through to count
int i = 0;
while (rows.MoveNext()) i++;
return i;
}
});
MessageBox.Show(String.Format(
"Total features that matched the search criteria: {0}", count));