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 9177355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:18:27+00:00 2026-06-17T17:18:27+00:00

I am trying to getting coordinates with the help of GPS and when i

  • 0

I am trying to getting coordinates with the help of GPS and when i am putting a dry run or debug the event makes PositionChange & StatusChange to call TWICE. Here is my code please help me.

  private void button1_Click(object sender, RoutedEventArgs e)
    {
        if (NetworkInterface.GetIsNetworkAvailable())
        {
            flag = true;
            if (watcher == null)
            {
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
                watcher.MovementThreshold = 20;
                watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
                watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
                watcher.Start();
            }
        }

    }


 void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
    {
        switch (e.Status)
        {
            case GeoPositionStatus.Disabled:
                MessageBox.Show("Location Service is not enabled on the device");
                break;

            case GeoPositionStatus.NoData:
                MessageBox.Show(" The Location Service is working, but it cannot get location data.");
                break;
        }
    }

  void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
    {
        if (e.Position.Location.IsUnknown)
        {
            MessageBox.Show("Please wait while your prosition is determined....");
            return;
        }

        List<string> locationData = new List<string>();
        locationData.Add(e.Position.Location.Latitude.ToString("Latitude:" + "0.000"));
        locationData.Add(e.Position.Location.Longitude.ToString("Longitude:" + "0.000"));
        locationData.Add(e.Position.Location.Altitude.ToString());
        locationData.Add(e.Position.Location.Speed.ToString());
        locationData.Add(e.Position.Location.Course.ToString());
}
  • 1 1 Answer
  • 0 Views
  • 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-06-17T17:18:28+00:00Added an answer on June 17, 2026 at 5:18 pm

    It’s called twice because the status changes from

    Initializing -> Ready

    For Initializing it fires once and For ready the second time 🙂

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

Sidebar

Related Questions

I am getting error trying to run my asp code for executing stored proc.
I am putting together a dynamic photo gallery and getting stuck trying to place
When compiling, I'm getting the following error when trying to return coordinates to the
I am trying to write a program that will send GPS coordinates using telnet.
Getting 401 errors when trying to use ASP.NET back end in load balanced environment
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Trying to install pear package and keep getting this strange error. Can you shed
I'm getting the following exceptions when trying to load a particular layout file in
I am getting strange errors while trying to create a simple database using isql
I am getting an error when trying to play a file in cakephp using

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.