Hexagon Geospatial
MENU

GeoMedia

Search for an answer, post a question, or answer other users' questions in our GeoMedia support discussions. This discussion board is a great way to collaborate with industry peers around the world. It is intended for discussion and support of the GeoMedia Desktop and Add-on applications.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 23
Registered: ‎11-02-2017
Accepted Solution

Disable Map View Update

Hello,

 

Is there a way to temporaily disable any updates from occuring on the map view while I add items to the legend?

 

I noticed that if I add a number of raster images using a single threaded piece of code, nothing appears in the MapView until the end of the thread. If I do the same thing with multi-threaded code, the raster images appear after each one is added. Is there a way to stop GeoMedia from updating automatically until I can issue a Refresh?

 

Many thanks in advance for your help!

 

This is my basic test code for adding a raster image. It shows a working single function approach and also an attempt to replicate a multithreaded environment approach.

 

' This function display all 4 raster images at the very end
Private Sub Working_Click(sender As Object, e As EventArgs) Handles Working.Click
    ' Create raster connection
    objConnEncrypted.Disconnect()

    With objConnEncrypted
      .Location = "..\raster.mdb"
      .Mode = PClient.ConnectionConstants.gmcModeReadOnly
      .Type = "Access.GDatabase"
      .Name = "raster.mdb"
      .CoordSystemsMgr = GMMapView1.CoordSystemsMgr
      .Connect()
    End With

    AddImage("Raster1", objConnEncrypted, True)
    AddImage("Raster2", objConnEncrypted, True)
    AddImage("Raster3", objConnEncrypted, True)
    AddImage("Raster4", objConnEncrypted, True)

    GMMapView1.Fit()
    GMMapView1.Refresh(True)

  End Sub

' This function display each raster image whenever the GeoMedia thread can execute. Simulated multithreading with DoEvents
Private Sub Notworking_Click(sender As Object, e As EventArgs) Handles Notworking.Click
    ' Create raster connection
    objConnEncrypted.Disconnect()

    With objConnEncrypted
      .Location = "..\raster.mdb"
      .Mode = PClient.ConnectionConstants.gmcModeReadOnly
      .Type = "Access.GDatabase"
      .Name = "raster.mdb"
      .CoordSystemsMgr = GMMapView1.CoordSystemsMgr
      .Connect()
    End With

    AddImage("Raster1", objConnEncrypted, True)
    Application.DoEvents()
    AddImage("Raster2", objConnEncrypted, True)
    Application.DoEvents()
    AddImage("Raster3", objConnEncrypted, True)
    Application.DoEvents()
    AddImage("Raster4", objConnEncrypted, True)
    Application.DoEvents()

    GMMapView1.Fit()
    GMMapView1.Refresh(True)

  End Sub


  Private Sub AddImage(name As String, connection As PClient.Connection, raster As Boolean)

    ' Create recordset
    connection.CreateOriginatingPipe(objOPipe)
    objOPipe.Table = name
    objRS = objOPipe.OutputRecordset

    ' Create new legend entry
    objLE = CreateObject("Geomedia.LegendEntry")
    objLE.GeometryFieldName = "Geometry"
    objLE.InputRecordset = objRS

    Dim objstyleservice As New PView.StyleService
    Dim objStyle As PView.StyleDefinition = Nothing
    If raster Then
      objstyleservice.GetStyle("Image Style", objStyle)
    Else
      objstyleservice.GetStyle("Area Style", objStyle)
    End If
    objLE.Style = objStyle

    objLE.LoadData()
    GMMapView1.Legend.LegendEntries.Append(objLE, 1)

  End Sub
Highlighted
Regular Contributor
Posts: 207
Registered: ‎05-25-2016

Re: Disable Map View Update

Hi adrianj

 

Btw: DoEvent is not multi-threading for procedure call. It's something like (pseudo)multi-threading for event processing. The code behavior in Working_Click doesn't use multi-threading.

 

Try to do the LoadData method at the end (outside AddImage) at the position of Fit and Refresh.

 

Best regards,

hesrah

Contributor
Posts: 23
Registered: ‎11-02-2017

Re: Disable Map View Update

Changing the order of the calls fixed the issue for me, thank you for the suggestion.

 

 

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.