// Use a builder convenience method or use a builder constructor.
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
// Builder convenience methods don't need to run on the MCT.
Polyline polyline = PolylineBuilder.CreatePolyline(list, SpatialReferences.WGS84);
// Builder constructors need to run on the MCT.
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (PolylineBuilder pb = new PolylineBuilder(list))
{
pb.SpatialReference = SpatialReferences.WGS84;
Polyline polyline2 = pb.ToGeometry();
}
});
// buildEx constructors don't need to run on the MCT
PolylineBuilderEx pBuilder = new PolylineBuilderEx(list);
pBuilder.SpatialReference = SpatialReferences.WGS84;
Polyline polyline3 = pBuilder.ToGeometry() as Polyline;
// builderEx convenience methods don't need to run on the MCT
// use AttributeFlags.NoAttributes because we only have 2d points in the list
Polyline polyline4 = PolylineBuilderEx.CreatePolyline(list, AttributeFlags.NoAttributes);