# InvalidOperationException

**URL:** <https://community.thinkgeo.com/t/invalidoperationexception/446>\
**Category:** WinForms\
**Created:** [May 29, 2009, 9:57am UTC](https://community.thinkgeo.com/t/invalidoperationexception/446 "2009-05-29T09:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rose](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@Rose](https://community.thinkgeo.com/u/Rose)\
**Post date:** [May 29, 2009, 9:57am UTC](https://community.thinkgeo.com/t/invalidoperationexception/446/1 "2009-05-29T09:57:52Z")

</div>

Hi,

I&nbsp;like&nbsp;the&nbsp;multthreaded&nbsp;mode&nbsp;in&nbsp;the&nbsp;new&nbsp;release,&nbsp;it&nbsp;is&nbsp;much&nbsp;faster,&nbsp;but&nbsp;I&nbsp;am&nbsp;getting&nbsp;too&nbsp;many&nbsp;exceptions&nbsp;in&nbsp;the&nbsp;latest&nbsp;release&nbsp;when&nbsp;using&nbsp;the&nbsp;multithreaded&nbsp;mode.&nbsp;Here&nbsp;is&nbsp;another&nbsp;exception,&nbsp;I&nbsp;retrieved&nbsp;lots&nbsp;of&nbsp;data&nbsp;in&nbsp;my&nbsp;PostgreFeature&nbsp;layer,&nbsp;then&nbsp;tracked&nbsp;zoom&nbsp;in,&nbsp;no&nbsp;response,&nbsp;then&nbsp;tracked&nbsp;zoom&nbsp;in&nbsp;again&nbsp;and&nbsp;again,&nbsp;got&nbsp;the&nbsp;exception.&nbsp;Here&nbsp;is&nbsp;the&nbsp;stack&nbsp;trace:

When&nbsp;will&nbsp;the&nbsp;MapSuite&nbsp;Desktop&nbsp;3.0&nbsp;get&nbsp;stablized?&nbsp;&nbsp;We&nbsp;have&nbsp;missed&nbsp;our&nbsp;deadline&nbsp;a&nbsp;lot,&nbsp;can't&nbsp;wait!

System.InvalidOperationException&nbsp;was&nbsp;unhandled  
  
&nbsp;&nbsp;Message="Collection&nbsp;was&nbsp;modified;&nbsp;enumeration&nbsp;operation&nbsp;may&nbsp;not&nbsp;execute."  
  
&nbsp;&nbsp;Source="mscorlib"  
  
&nbsp;&nbsp;StackTrace:  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Collections.Generic.List`1.Enumerator.MoveNextRare()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Collections.Generic.List`1.Enumerator.MoveNext()  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.InMemoryFeatureSource.GetFeaturesInsideBoundingBoxCore(RectangleShape&nbsp;boundingBox,&nbsp;IEnumerable`1&nbsp;returningColumnNames)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawingCore(RectangleShape&nbsp;boundingBox,&nbsp;Double&nbsp;screenWidth,&nbsp;Double&nbsp;screenHeight,&nbsp;IEnumerable`1&nbsp;returningColumnNames)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesForDrawing(RectangleShape&nbsp;boundingBox,&nbsp;Double&nbsp;screenWidth,&nbsp;Double&nbsp;screenHeight,&nbsp;IEnumerable`1&nbsp;returningColumnNames)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas&nbsp;canvas,&nbsp;Collection`1&nbsp;labelsInAllLayers)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas&nbsp;canvas,&nbsp;Collection`1&nbsp;labelsInAllLayers)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.DesktopEdition.ExtentInteractiveOverlay.DrawCore(GeoCanvas&nbsp;canvas)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas&nbsp;canvas)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x27d0591c2adda8d9(RectangleShape&nbsp;xb35a33b423b17f65,&nbsp;Overlay&nbsp;x99251f66cdabc2ad,&nbsp;Int32&nbsp;xa209325f5c895f7e,&nbsp;Int32&nbsp;x7454a0d1965919b1,&nbsp;GeographyUnit&nbsp;xbb704b4400ce6f76)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x27d0591c2adda8d9(Object&nbsp;x9c95f4613bdc3113)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ExecutionContext.runTryCode(Object&nbsp;userData)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode&nbsp;code,&nbsp;CleanupCode&nbsp;backoutCode,&nbsp;Object&nbsp;userData)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.ExecutionContext.Run(ExecutionContext&nbsp;executionContext,&nbsp;ContextCallback&nbsp;callback,&nbsp;Object&nbsp;state)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallbackInternal(\_ThreadPoolWaitCallback&nbsp;tpWaitCallBack)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.Threading.\_ThreadPoolWaitCallback.PerformWaitCallback(Object&nbsp;state)  
  
&nbsp;&nbsp;InnerException:&nbsp;  
  
&nbsp;

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [June 1, 2009, 5:19am UTC](https://community.thinkgeo.com/t/invalidoperationexception/446/2 "2009-06-01T05:19:24Z")

</div>

Rose,&nbsp;  
  
  
  
It&nbsp;seems&nbsp;a&nbsp;threading&nbsp;issue&nbsp;from&nbsp;the&nbsp;exception&nbsp;description.&nbsp;Can&nbsp;you&nbsp;show&nbsp;me&nbsp;your&nbsp;code&nbsp;as&nbsp;maybe&nbsp;something&nbsp;is&nbsp;wrong&nbsp;there.&nbsp;We&nbsp;had&nbsp;a&nbsp;test&nbsp;with&nbsp;190,000&nbsp;records&nbsp;in&nbsp;postgre,&nbsp;display&nbsp;it&nbsp;and&nbsp;keep&nbsp;tracking&nbsp;zoom&nbsp;in,&nbsp;and&nbsp;it&nbsp;works&nbsp;fine.&nbsp;Here&nbsp;is&nbsp;the&nbsp;code:&nbsp;  
  
  
  
`private void Form1_Load(object sender, EventArgs e)        {            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;            winformsMap1.CurrentExtent = new RectangleShape(-126.4, 48.8, -67.0, 19.0);            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);            string connectString = "Server=192.168.0.212;User Id=postgres;Password=thinkgeo;DataBase=postgis;";            PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "rail", "oid");            postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Railway1;            postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;                        LayerOverlay staticOverlay = new LayerOverlay();            staticOverlay.Layers.Add("PostgreLayer", postgreLayer);            winformsMap1.Overlays.Add(staticOverlay);            winformsMap1.Refresh();        }`  
  
Finally,&nbsp;are&nbsp;you&nbsp;using&nbsp;X64&nbsp;version?&nbsp;we&nbsp;will&nbsp;have&nbsp;more&nbsp;tests&nbsp;on&nbsp;that&nbsp;if&nbsp;you&nbsp;are.&nbsp;  
  
  
  
Thanks,&nbsp;  
  
  
  
Ben
