【发布时间】:2015-01-16 01:11:13
【问题描述】:
我开始在 C# 中使用 Gmaps,我注意到有时当我在调试模式下运行程序并退出它时,仍然有一些 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,但您似乎没有正确处理资源。 GoogleMap 类是否实现了 IDisposable 模式?
-
是的,我尝试使用 .Dispose() 它仍然会继续发生
标签: c# multithreading gmap.net