Hi, I want to update a Label-Content from values found in a QueuedTask.
How can I access the GUI?
ArcGISpro 2.9, VS2019, .NET 4.8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ArcGIS.Core.Data;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using System.Windows.Threading;
namespace AttributeValues
{
/// <summary>
/// Interaction logic for ProWindow1.xaml
/// </summary>
public partial class ProWindow1 : ArcGIS.Desktop.Framework.Controls.ProWindow
{
public ProWindow1()
{
InitializeComponent();
}
private void Button_1_Click(object sender, RoutedEventArgs e)
{
var map = MapView.Active?.Map;
FeatureLayer layer = map.FindLayers("streets").FirstOrDefault() as FeatureLayer;
getNames(layer);
}
private static async Task getNames(FeatureLayer layer)
{
QueuedTask.Run(() =>
{
try
{
string sWhereClause = "42 = 42";
string sPostfixClause = "ORDER BY name";
string sSubFields = "name";
QueryFilter queryFilter = new QueryFilter();
queryFilter.WhereClause = sWhereClause;
queryFilter.PostfixClause = sPostfixClause;
queryFilter.SubFields = sSubFields;
RowCursor rows = layer.Search(queryFilter);
while (rows.MoveNext())
{
var curRow = rows.Current;
string sName = curRow.GetOriginalValue(curRow.FindField("name")).ToString();
// Write sName to Label_1 in ProWindow1 to see the progress!!!
// DO SOMETHING WITH THE STREET ...
System.Diagnostics.Debug.Print(sName);
} // while
return true;
} // try
catch (Exception exc) { System.Windows.MessageBox.Show(exc.Message); return false; }
}).Wait();
}
}
}