.NET Components for Mobility

Raw GPS Event

Last post 02-18-2008 3:28 PM by PeterFoot. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-11-2008 2:31 PM

    Raw GPS Event

     Hi Peter 

    I  am getting a few problems with consistency within my trial application, can you please advise me on the following. I wish to load form1 and have an instance of navigator running in the background (hidden behind form1) the load event assigns a handler to the RawGpsReceived  event.

     AddHandler n.RawGpsReceived, AddressOf n_RawGpsReceived 

    When this event fires I wish to activate a timer that periodically will activate the background worker to plot the gps data. The problem is that the event doe’s not always fire when data is being received. Form1 load event is below.

      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load        Try            n = New InTheHand.TomTom.Navigator            AddHandler n.RawGpsReceived, AddressOf n_RawGpsReceived            bw = New BackgroundWorker(Me)            If (n.RouteInfo.IsPlanned) Then n.ClearRoute()            AddHandler bw.DoWork, AddressOf bw_DoWork            AddHandler bw.RunWorkerCompleted, AddressOf bw_RunWorkerCompleted Catch ex As Exception            MsgBox(Err.Description, MsgBoxStyle.Critical, "Load Event")        End Try    End Sub ‘rawgpsreceived Private Sub n_RawGpsReceived(ByVal sender As Object, ByVal e As RawGpsReceivedEventArgs)        Try                        RawCancel()         Catch ex As Exception            MsgBox(Err.Number, MsgBoxStyle.Critical, "Raw GPS")        Finally            RawCancel()        End Try    End Sub 

    When I check navigator the gps data is being plotted but the RawGpsReceived event has not fired. On other occaisions the evvnt doe's fire?

     

    Regards,

    Joe

     

    Filed under:
  • 02-12-2008 4:15 AM In reply to

    Re: Raw GPS Event

    What happens in the RawCancel() routine? Since the RawGpsReceived event occurs very frequently it's important you don't have any long-running routines called in this event handler.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
  • 02-12-2008 3:12 PM In reply to

    Re: Raw GPS Event

    Hi Peter,

    Thanks for your response. I only want the raw event to kick start the background worker (ensuring that the device is receiving data) which in turn writes the position data to a sqlce table on the device, the timer is set by the bwRoute_RunWorkerCompleted routine to update the position data by calling the background worker periodically (no more often than every 15 minutes). When the raw event works everything else falls into place quite neatly.  I am not able to achieve this consistently.

    Regards,

    Joe

     

    'Code

     

    Private Sub RawCancel()

    Try

    RemoveHandler n.RawGpsReceived, AddressOf n_RawGpsReceived

    bw.RunWorkerAsync()

    Catch ex As Exception

    MsgBox(Err.Description)

    End Try

    End Sub

  • 02-18-2008 3:28 PM In reply to

    Re: Raw GPS Event

    Have you tried taking out your code from the event handler and just logging every time the event is raised - Debug.WriteLine for example. Normally this event will be triggered every second or more with normal GPS data. If you only want to catch the event every 15 mins you could log the current time and check the time against this value every time the event is raised, once the two values are greater than 15 mins then you call your backgroundWorker.

    Peter

    Peter Foot
    Microsoft Device Application Development MVP
    www.peterfoot.net | www.inthehand.com
Page 1 of 1 (4 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.