| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
You may want to cast it to FeatureClass.
To ensure maximum robustness, callers should explicitly dispose of the returned ArcGIS.Core.Data.Table in either a using statement or a finally block.
{
await QueuedTask.Run(() =>
{
IEnumerable<Layer> layers =
MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
foreach (FeatureLayer featureLayer in layers)
{
using (Table table = featureLayer.GetTable())
using (Datastore datastore = table.GetDatastore())
{
if (datastore is UnknownDatastore)
continue;
Geodatabase geodatabase = datastore as Geodatabase;
}
}
});
}
{
//Must be called within QueuedTask.Run()
void GetCount(FeatureLayer featureLayer)
{
// Row count in a Table
Table table = featureLayer.GetTable();
long count = table.GetCount();
// Feature count in a FeatureClass
FeatureLayer lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
FeatureClass featureClass = lyr.GetFeatureClass();
count = featureClass.GetCount();
}
}
{
// Note: QueuedTask is required to access the AnnotationFeature
{
using var table = annotationLayer.GetTable();
using var rc = table.Search();
rc.MoveNext();
using var af = rc.Current as AnnotationFeature;
var graphic = af.GetGraphic();
var textGraphic = graphic as CIMTextGraphic;
//Note:
//var outline_geom = af.GetGraphicOutline();
//gets the anno text outline geometry...
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)