当我关闭应用程序时,一些线程不会停止使用Gmap

本文关键字:Gmap 线程 应用程序 | 更新日期: 2023-09-27 18:25:16

我开始为C#使用Gmap,我注意到有时当我在调试模式下运行程序并退出它时,仍然有一些Gmap线程在运行(我假设这就是发生的事情),所以程序无法完成执行,我需要按停止调试。我真的不希望这种情况在节目结束后继续发生。

那么,有没有办法在GMapControl中强制关闭线程,或者发生了其他事情?

  public class GoogleMap : GMapControl
  {
        public GoogleMap() : base ()
        {
              this.MapProvider = GMapProviders.GoogleMap;
              this.Position = new PointLatLng(46.6682870738831, 15.9823608398438);
              this.MinZoom = 1;
              this.MaxZoom = 17;
              this.Zoom = 9;
              this.Location = new Point(0, 24);
              this.DragButton = MouseButtons.Left;
              originalWidth = Obj.mainForm.ClientRectangle.Width;
              originalHeight = Obj.mainForm.ClientRectangle.Height;
              this.Dock = DockStyle.Fill;
        }
  }

这是我使用的构造函数,然后我只需使用将GoogleMap对象添加到我的主表单中

GoogleMap map = new GoogleMap();
this.Controls.Add(map);

当我关闭应用程序时,一些线程不会停止使用Gmap

它是后台缓存,几分钟后就会停止,如果你想立即退出,请调用退出map.Manager.CancelTileCaching();