Question

I have the following code:

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());
}
}

This should load form and enable interactions with it while mpControl_LoadRegion is running. It takes from 5 to 10 seconds to load map point regions thus why I am doing it asynchronously.

However iar.CompletedSynchronously is always false.

What am I missing?

Was it helpful?

Solution

The CompletedSynchronously Property indicates whether the operation was completed synchronously rather than asynchronously. It doesn't mean that the operation wasn't completed at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top