DotSpatial app never exits when has SHP layer

Jul 30, 2014 at 12:36 AM
Hi! I'm using dotSpatial to display shapefile over brutile layer in my WPF application.
Everything works good, but if I close the application it never exits and just hangs.
It happens if my shapefile (shp+dbf) is about 8MB. If I'm loading small file (50-100KB) then the app exits good. Also If I don't add shapefile into Map control (but still open the shapefile) everything works good.
My code:
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      var map = (Map)FormsHost.Child;
      var pathNoExt = "shapefile";

      var featureSet = FeatureSet.OpenFile(pathNoExt + ".shp");
      featureSet.Projection = ProjectionInfo.FromEsriString(File.ReadAllText(pathNoExt + ".prj"));
      map.ProjectionModeDefine = ActionMode.Never;
      map.ProjectionModeReproject = ActionMode.Never;
      var bingAerialLayer = new BruTileLayer(new BingLayerConfiguration("cache", BingMapType.Aerial));
      featureSet.Reproject(bingAerialLayer.Projection);
      map.Layers.Add(bingAerialLayer);
      map.CollisionDetection = true;
      // !!! if comment this line, the app exits normally
      map.Layers.Add(featureSet);
      
      map.FunctionMode = FunctionMode.Pan;
      
      map.ViewExtents = featureSet.Extent;
      map.Projection = bingAerialLayer.Projection;
    }
  }

Xaml:
<Window x:Class="DotSpatialSample1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:DotSpatial.Controls;assembly=DotSpatial.Controls"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <WindowsFormsHost x:Name="FormsHost">
          <controls:Map></controls:Map>
        </WindowsFormsHost>
    </Grid>
</Window>
You can look at Parallel stacks windows in VS after I click Close in my app here
https://yadi.sk/i/QZQoeyExYQNQi
Will be glad for any help.
Developer
Jul 30, 2014 at 8:06 AM
Hi,
i'm not sure that this is somehow depends on shapefile size. It may depends from WPF\WinForms.
WPF WindowsFormsHost usually works slow and potentially can hang up applicaton. The better use WinForms applicaiton.
Jul 30, 2014 at 11:40 AM
Winforms in 2014 - really bad approach)
It's strange that it happens only if I add this layer into map, so I guess there is some dependency on shapefile.