//Creates a new map frame and changes the camera's scale.
//Constuct on the worker thread
await QueuedTask.Run(() =>
{
//Build geometry
Coordinate2D ll = new Coordinate2D(6.0, 8.5);
Coordinate2D ur = new Coordinate2D(8.0, 10.5);
//At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(ll, ur);
Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur);
//Reference map, create MF and add to layout
MapProjectItem mapPrjItem = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map"));
Map mfMap = mapPrjItem.GetMap();
//At 2.x - mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap);
// mfElm.SetName("New Map Frame");
mfElm = ElementFactory.Instance.CreateMapFrameElement(layout, env, mfMap, "New Map Frame");
//Set the camera
Camera camera = mfElm.Camera;
camera.Scale = 24000;
mfElm.SetCamera(camera);
});