Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 954553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:14:01+00:00 2026-05-16T00:14:01+00:00

I have a GPS class which i obviously use to acquire the latitudes and

  • 0

I have a GPS class which i obviously use to acquire the latitudes and longitudes.

The UpdateData() is called when the gps state or location is changed. So i make sure that both the Latitude and Longitude is valid and then i make the DataReady bool equal to true.

So i use this code in a fairly n00b fashion where i use a Timer (Windows Form’s one) and check getGPSCoordinates() every 10 seconds to see whether a valid location is found (getGPSCoordinates() is not null) and if not, do the rest of code. This is used, as it may take from 10 seconds to maybe even 1 minute to get a clear gps signal.

So although this works fine, i know this is not the correct way to do this. I think whole GPS business should be carried on a separate thread and it should notify the main thread that the location is changed and the data is ready.

Can someone point me on the correct way of handling these kinds of business? Should i use IAsyncResult to notify the main thread?

bool DataReady = false;

private void UpdateData()
        {

            if (gps.Opened)
            {
                if (position != null)
                {

                    if (position.LatitudeValid)
                    {
                        Latitude =  position.Latitude.ToString();
                    }


                    if (position.LongitudeValid)
                    {
                        Longitude = position.Longitude.ToString();

                    }

                    if (Latitude != null && Longitude != null)
                        DataReady = true;          


                }



            }


 public string getGPSCoordinates()
        {
            if (DataReady)
            {
                return String.Format("http://maps.google.com/maps/api/staticmap?sensor=false&size=500x500&markers=color:red|label:A|{0},{1}&zoom=15&maptype=hybrid", Latitude, Longitude);
            }
            else
                return null;
        }


        }
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:14:02+00:00Added an answer on May 16, 2026 at 12:14 am

    It sounds like you want to use a BackgroundWorker – however this isn’t natively supported in the Compact Framework. Again however, this can be addressed:

    Is there a BackgroundWorker replacement for .NET Compact Framework 3.5?

    You can then call into your background worker whenever your UI timer ticks (make sure to pause your UI timer until you get a response).

    If you cannot use the implemented BackgroundWorker from that question, you will need to maintain a Queue or List that both the UI and the background can see. Using a normal thread will likely mean registering a callback (fairly standard, using your IAsyncResult idea) however this callback is run on an unknown, arbitrary thread – this makes updating your UI a little finicky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that extends AsyncTask , which fetches the gps cordinates from
I have created a GPS service which reads location updates on a regular interval.
I have an activity called message.java which is bound to the service GPS.java. The
I have main activity which call other object, for example GPS class. This GPS
I have a GPS class which returns the current GPS coordinates to the calling
I have a class LocationHelper which I am designing to obtain a user location.
have an app that finds your GPS location successfully, but I need to be
I have written an iPhone app that uses the iPhone's relative GPS location. I
i am developing app in Blackberry which have GPS Functionality. so first i want
I'm porting android to Devkit8000 which is a BeagleBoard clone. I have a GPS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.