Skip to main content
 首页 » 编程设计

c#之当我关闭应用程序时,一些线程不会随着 Gmap 停止

2024年02月06日34mfrbuaa

我开始使用 C# 的 Gmaps,我注意到有时当我在 Debug模式下运行程序并退出它时,仍然有一些 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); 

请您参考如下方法:

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