我有以下代码:
public partial class Main : Form
{
private delegate void LoadMapPointRegion();
private LoadMapPointRegion lmprd;
private MapPoint.Application mpApp;
private MapPoint.Map mpMap;
public Main()
{
InitializeComponent();
lmprd = new LoadMapPointRegion(mpControl_LoadRegion);
lmprd.BeginInvoke(new AsyncCallback(mpControl_RegionLoaded), null);
}
private void mpControl_LoadRegion()
{
mpControl.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);
mpMap = mpControl.ActiveMap;
mpApp = mpMap.Application;
}
private void mpControl_RegionLoaded(IAsyncResult iar)
{
MessageBox.Show("MapPoint loaded async: " + iar.CompletedSynchronously.ToString());
}
}
这应该在运行时加载表单并启用与它的交互mpControl_LoadRegion
。加载地图点区域需要 5 到 10 秒,因此我异步执行此操作。
然而iar.CompletedSynchronously
总是假的。
我错过了什么?