Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
1. When creating a geometry using a convenience method on the builder and a value for the attribute or an object with attribute awareness is passed as a parameter.
2. When creating a geometry from the builder ToGeometry method and a geometry of the same type with attribute awareness was passed to the builder constructor.
3. When creating a MapPoint from MapPointBuilder.ToGeometry and a value for the attribute was passed to the builder constructor.
// Use a builder convenience method or use a builder constructor. MapPoint point1 = null; // Builder constructors need to run on the MCT. ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0)) { bool bhasZ = mb.HasZ; // hasZ = true bool bhasM = mb.HasM; // hasM = false bool bhasID = mb.HasID; // hasID = false // do something with the builder point1 = mb.ToGeometry(); } }); double x = point1.X; // x = 1.0 double y = point1.Y; // y = 2.0 double z = point1.Z; // z = 3.0 double m = point1.M; // m = Nan int ID = point1.ID; // ID = 0 bool hasZ = point1.HasZ; // hasZ = true bool hasM = point1.HasM; // hasM = false bool hasID = point1.HasID; // hasID = false bool isEmpty = point1.IsEmpty; // isEmpty = false // Builder convenience methods don't need to run on the MCT. MapPoint point2 = MapPointBuilder.CreateMapPoint(point1); x = point2.X; // x = 1.0 y = point2.Y; // y = 2.0 z = point2.Z; // z = 3.0 m = point2.M; // m = Nan hasZ = point2.HasZ; // hasZ = true hasM = point2.HasM; // hasM = false hasID = point2.HasID; // hasID = false
// list of points List<MapPoint> points = new List<MapPoint> { MapPointBuilder.CreateMapPoint(0, 0, 2, 3, 1), MapPointBuilder.CreateMapPoint(1, 1, 5, 6), MapPointBuilder.CreateMapPoint(2, 1, 6), MapPointBuilder.CreateMapPoint(0, 0) }; // will have attributes because it is created with convenience method Polyline polylineWithAttrs = PolylineBuilder.CreatePolyline(points); bool hasZ = polylineWithAttrs.HasZ; // hasZ = true bool hasM = polylineWithAttrs.HasM; // hasM = true bool hasID = polylineWithAttrs.HasID; // hasID = true // will have attributes because it is created with convenience method Polygon polygonWithAttrs = PolygonBuilder.CreatePolygon(points); hasZ = polygonWithAttrs.HasZ; // hasZ = true hasM = polygonWithAttrs.HasM; // hasM = true hasID = polygonWithAttrs.HasID; // hasID = true // Builder constructors need to run on the MCT. ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { // will not have attributes because it is passed something other than an attributed polyline using (PolylineBuilder polylineB = new PolylineBuilder(points)) { hasZ = polylineB.HasZ; // hasZ = false hasM = polylineB.HasM; // hasM = false hasID = polylineB.HasID; // hasID = false } // will have attributes because it is passed an attributed polyline using (PolylineBuilder polylineB = new PolylineBuilder(polylineWithAttrs)) { hasZ = polylineB.HasZ; // hasZ = true hasM = polylineB.HasM; // hasM = true hasID = polylineB.HasID; // hasID = true } // will not have attributes because it is passed something other than an attributed polygon using (PolygonBuilder polygonB = new PolygonBuilder(points)) { hasZ = polygonB.HasZ; // hasZ = false hasM = polygonB.HasM; // hasM = false hasID = polygonB.HasID; // hasID = false } // will have attributes because it is passed an attributed polygon using (PolygonBuilder polygonB = new PolygonBuilder(polygonWithAttrs)) { hasZ = polygonB.HasZ; // hasZ = true hasM = polygonB.HasM; // hasM = true hasID = polygonB.HasID; // hasID = true } });
Target Platforms: Windows 10, Windows 8.1, Windows 7