.NET Components for Mobility

GPS related Object disposed exception in V 3.3/4.0

Last post 02-14-2010 6:16 PM by PeterFoot. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-10-2010 6:35 PM

    • KiwiDev
    • Top 500 Contributor
    • Joined on 10-08-2008
    • Christchurch,New Zealand
    • Posts 5

    GPS related Object disposed exception in V 3.3/4.0

    Every so often I get an object disposed exception when shutting down my application.
     
    It happens in my code on the hits the invoke line 
     
    void gps_PositionChanged(object sender, EventArgs e)
    {
    if (gps == null)
    {
    return;
    }
     
    this.Invoke(new UpdateFixStatusDelegate(UpdateFixStatus), gps.IsValid);

    // Bug out of GPS values invalid
    if (!gps.IsValid)
    {
    return;
    }

    Then before returning I do some basic spatial maths to see if point needs to be logged.
    }
     
     
    I initialise the GPS here
    private void frmMain_Load(object sender, EventArgs e)
    {
    // Register the callbacks for GPS
    gps.PositionChanged += new EventHandler(gps_PositionChanged);
     
    .........
     
     
    Shut everything down here
    private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
    // Stop any GPS communications
    gps.PositionChanged -= new EventHandler(gps_PositionChanged);
    gps.Close();
    }
     
     
    More Information 
    Running software on WIndows Mobile 6.5 Professional device an HTC Touch Pro II
     
    I built the GPSReader Sample application using InTHeHand V 4.0 and it appears to have the same sort of issue.
     
    private void gps1_PositionChanged(object sender, EventArgs e)

    {

    this.Invoke(new InTheHand.Windows.Forms.MethodInvoker(PositionChanged));

    }

    on the this.Invoke get an objectdisposed exception
     
    ObjectName in debug view detail is ""
     
    "   at System.Windows.Forms.Control.InvokeHelper(Delegate method, Boolean fSynchronous, Object[ rgobjArgs)\r\n   at System.Windows.Forms.Control.Invoke(Delegate method)\r\n   at GpsReader.GpsForm.gps1_PositionChanged(Object sender, EventArgs e)\r\n   at InTheHand.WindowsMobile.Gps.Gps.Worker()\r\n" 
     
     
    I then added HDoP display to the form as the value that was being displayed in another application was odd.
     
    private void PositionChanged()

    {

    lblLat.Text = gps1.Latitude.ToString();

    lblLon.Text = gps1.Longitude.ToString();

    lblAlt.Text = gps1.AltitudeWRTSeaLevel.ToString();

    lblHDoP.Text = gps1.HorizontalDilutionOfPrecision.ToString();

    }

    The HDoP value seemed to regularly toggle from 666.6 to a reasonable looking value.

     

  • 02-12-2010 4:11 PM In reply to

    Re: GPS related Object disposed exception in V 3.3/4.0

    Thanks for reporting this, I'm looking into this issue. I'm also adding a few capabilities to the GPS support for example the ability to specify a minimum distance so that you only need to respond to location changes when there has been a significant movement.

    Peter

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

    Re: GPS related Object disposed exception in V 3.3/4.0

    I've noticed this issue can occur occasionally, the 4.1 release will have a fix for this. As a workaround for the current build you should be able to wrap all the code in your PositionChanged event handler in a try/catch block.

    Regarding HDOP, I too see the value 666.6 returned. This often occurs when the fix type is returned as Unknown or the number of satellites is low. However according to the flags on the raw position data this is a valid field. I think the reasoning behind this is that the DOP values are sent within the $GPGSA sentence and are only updated every few seconds whereas the actual position is updated in the $GPRMC every second or so. So even though the value has yet to be updated the API is reporting it as valid. The maximum documented value for this field is 50 so it appears this is a bug in the GPS driver. For the next release I'll add a workaround to catch invalid values. As a workaround you can ignore values over 50.0.

    Peter

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

    • KiwiDev
    • Top 500 Contributor
    • Joined on 10-08-2008
    • Christchurch,New Zealand
    • Posts 5

    Re: GPS related Object disposed exception in V 3.3/4.0

    Thanks Peter,

    Do you have an ETA for 4.1?

    I have a delivery coming up and I was wondering if it was worth waiting ? (Do you want any testers?)

    Bryn

  • 02-14-2010 6:16 PM In reply to

    Re: GPS related Object disposed exception in V 3.3/4.0

    I don't have a date for 4.1 yet but I can include you in testing. I will send you an email with details.

    Regarding HDOP values I observed that the HDOP/VDOP/PDOP all return 666.6 in situations where the signal is very weak, although Fix3D is returned the actual satellite count was 2 which would indicate a poor 2d fix at best so the GPS API is returning conflicting information.

    Peter

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