ThinkGeo.com    |     Documentation    |     Premium Support

CurrentScale - error "Cannot evaluate expression because the current thread is in a stack overflow state"

Hi,

We use ThinkGeo.MapSuite.DesktopEdition and

MapControl Settings:

MapControl.MinimumScale = 600; // default 200
MapControl.MaximumScale = 1156000; // default 80000000000000
MapControl.ZoomLevelSnapping = ZoomLevelSnappingMode.None;

Event handler

MapControl_CurrentScaleChanged(object sender, CurrentScaleChangedWinformsMapEventArgs e)
{
double current_scale = MapControl.CurrentScale;
}

It looks MinimumScale does not restrict zoom-in to lower scale and we got error in Event handler MapControl_CurrentScaleChanged(). The error cannot be controlled by try-catch blocks. The error says “Cannot evaluate expression because the current thread is in a stack overflow state”.

Any idea that we did wrong in calling MapControl.CurrentScale property?

Please help and thanks in advance,

Mengbo

Hi Mengbo,

Please try the following code to get the current scale:

 private void WinformsMap1_CurrentScaleChanged(object sender, CurrentScaleChangedWinformsMapEventArgs e)
 {
     double current_scale = e.CurrentScale;
 }

The MapControl.CurrentScale calls the set_CurrentExtent internally, and then the set_CurrentExtent raises the CurrentScaleChangedEvent, in this case it creates a endless loop.

Thanks,
Peter

Hi Peter,

Yes, your code works and stops the overflow caused the endless loop.

You are great and thank you so much!

Mengbo

Hi Mengbo,

You’re welcome, very glad to hear it works for you.

Thanks,
Peter