GmapControl Freezing

Topics: Windows Forms
Dec 7, 2012 at 11:13 AM

Hello, I have a run a thread but lock GmapControl

 

Public delegate void RPTDelegate();
RPTDelegate puntRPT = new RPTDelegate(RPT);
private void RPT()
{
	if (this.InvokeRequired) {
		this.Invoke(puntRPT);

	} else {
		while (true) {
			GMapOverlay ov = lstOverlay.Find(new Predicate<GMapOverlay>((GMapOverlay obj) => { return obj.Id == "TRAM"; }));
			DataTable Tbl = new DataTable();
			DataSet ds = new DataSet();
			try {
				ds.ReadXml("xml.xml");
				Tbl = ds.Tables[0];
				for (int i = 0; i <= Tbl.Rows.Count - 1; i++) {
					foreach (object ele_loopVariable in ov.Markers) {
						ele = ele_loopVariable;
						if (Tbl.Rows[i]["VEICOLO"].ToString() == ele.ToolTipText) {
							ele.Position = new PointLatLng(Fn.cnDouble(Tbl.Rows[i]["LAT"].ToString().Replace(".", ",")), Fn.cnDouble(Tbl.Rows[i]["LON"].ToString().Replace(".", ",")));
							GMapControl1.Refresh();
							break; 
						}
					}
				}

			} catch (Exception ex) {
			}
			System.Threading.Thread.Sleep(1800);
		}
	}

}
Dec 7, 2012 at 11:17 AM

without thread, it works, but as overlays are many in the form begins to freeze

Dec 7, 2012 at 11:55 AM

don't call GMapControl1.Refresh();

Dec 7, 2012 at 12:12 PM
Edited Dec 7, 2012 at 12:13 PM

still don't work, also any button don't work

Dec 7, 2012 at 12:58 PM

there are 3 real time demos integrated, works perfectly, handles thousand of markers, check the code...

Dec 7, 2012 at 2:35 PM

 

I need to change the properties of a marker every 5 seconds, what can I do in order not to block the mask? I've tried using a timer but does not work as it should

Dec 7, 2012 at 2:48 PM
  • 1 refresh per batch update

Map.HoldInvalidation = true;
{
  for(;;)
  {
    m1.Position = new ...
    m2.Position = new ..
  }
}
MainMap.Refresh();

..for me backgroundWorker works just fine, both wpf/forms. Get the data in DoWork and call ReportProgress to update the visual objects

Marked as answer by radioman on 6/4/2014 at 3:38 PM
Dec 10, 2012 at 10:01 AM

hi, I've never used ReportProgress in BackgroundWorker you give me an example?

Dec 10, 2012 at 10:11 AM

I associate a new location at the marker every 3000 ms, and it makes me lock the form.I get the positions through xml and I get the new positions at different times, so call the BackgroundWorker often by a timer.But all this does not make me navigate around the map

Dec 10, 2012 at 10:22 AM

check the demos code... it's nothing hard or advanced, just usual backgroundworker and some simple logic...

Dec 10, 2012 at 11:08 AM

I use this method

Map.HoldInvalidation = true;
{
  for(;;)
  {
    m1.Position = new ...
    m2.Position = new ..
  }
}
MainMap.Refresh();

 

but for some time visualize the duplication

Dec 10, 2012 at 12:38 PM

?

Dec 10, 2012 at 1:30 PM

 

http://s12.postimage.org/5d8qnz4sd/Immagine.png

Dec 10, 2012 at 1:37 PM

Well you are doing something wrong ;/

Dec 10, 2012 at 1:49 PM

I HAVE FOLLOWING YOUR SPECIFIC:

This is the code my BackgroundWorker:

GMapControl1.HoldInvalidation = True

            For Each linea In lstLinee

                ds.ReadXml("http://www.anm.it/srv_web/srvInfoANM.aspx?pos=" & linea.LINEA) 

              Tbl = ds.Tables(0)

               Dim dv As New DataView(Tbl)

                For Each ele In linea.lstLinee

                 Try

                        dv.RowFilter = "VEICOLO =" & Dichiarazioni.DB.fKeyStrW(ele.ToolTipText)

                        Dim tblInt As DataTable = dv.ToTable

                        If tblInt.Rows.Count > 0 Then

                            ele.Position = New PointLatLng(Fn.cnDouble(tblInt.Rows(0)("LAT").ToString.Replace(".", ",")), Fn.cnDouble(tblInt.Rows(0)("LON").ToString.Replace(".", ",")))

                        End If

                    Catch ex As Exception

                        Debug.WriteLine(ex.Message)

                    End Try

                Next

            Next

            GMapControl1.Refresh()

 

THIS HAPPENS WHEN ZOOM EFFECT OR I click on the MAP

Dec 10, 2012 at 2:54 PM

it's wrong, you do data reading and map update on the same thread, check the source man...

Dec 10, 2012 at 3:49 PM

 

here is only reading new data, markers are created in gmaploadù

do not get me wrong