Hi,
I've searched on forums but couldn't find similar problem.
I have a one LayerOverlay and I'm loading an image on it with code:
wpfMap1.MapUnit = GeographyUnit.DecimalDegree; GdiPlusRasterLayer imageMapLayer = new GdiPlusRasterLayer(mapToLoad.Path); imageMapLayer.UpperThreshold = double.MaxValue; imageMapLayer.LowerThreshold = 0; LayerOverlay overlay = new LayerOverlay(); overlay.Layers.Add(imageMapLayer); overlay.RenderMode = RenderMode.GdiPlus; overlay.TileType = TileType.SingleTile; imageMapLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException; wpfMap1.Tag = mapToLoad; wpfMap1.Overlays.Clear(); wpfMap1.Overlays.Add(overlay); wpfMap1.Refresh();
And when zooming in/out fastly (while it is still refreshing) if I click on globe button I get below exception;
System.InvalidOperationException was unhandled
Message=Object is currently in use elsewhere.
Source=System.Drawing
StackTrace:
at System.Drawing.Image.get_Width()
at ThinkGeo.MapSuite.Core.GdiPlusRasterSource.GetImageWidthCore()
at ThinkGeo.MapSuite.Core.GdiPlusRasterSource.GetBoundingBoxCore()
at ThinkGeo.MapSuite.Core.RasterSource.GetBoundingBox()
at ThinkGeo.MapSuite.Core.RasterLayer.GetBoundingBoxCore()
at ThinkGeo.MapSuite.Core.Layer.GetBoundingBox()
at ThinkGeo.MapSuite.WpfDesktopEdition.LayerOverlay.GetBoundingBoxCore()
at ThinkGeo.MapSuite.WpfDesktopEdition.Overlay.GetBoundingBox()
at ThinkGeo.MapSuite.WpfDesktopEdition.PanZoomBarMapTool.RxY=(Object SBY=, MouseButtonEventArgs SRY=)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WinformsMapTest.Program.Main() in D:\__nanodems__\nanodems.maps.V2\WinformsMapTest\Program.cs:line 24
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
What can be the reason and how we can I avoid this situation?
Regards