GeoPositionStatus Enumeration

GeoPositionStatus Enumeration

.NET Framework (current version)
 

Indicates the ability of the location provider to provide location updates.

Namespace:   System.Device.Location
Assembly:  System.Device (in System.Device.dll)

public enum GeoPositionStatus

Member nameDescription
Disabled

The location provider is disabled. On Windows 7, this is the case when the Sensor and Location platform has been disabled by group policy.

Initializing

The location provider is initializing. For example, a GPS that is still obtaining a fix has this status.

NoData

No location data is available from any location provider.

Ready

A location provider is ready to supply new data.

The following example shows how to handle StatusChanged events and print out the current GeoPositionStatus.

using System;
using System.Device.Location;
namespace ShowStatusUpdates
{
    class Program
    {
        static void Main(string[] args)
        {
            ShowStatusUpdates();
        }

        static void ShowStatusUpdates()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
            watcher.Start();

            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);

            Console.WriteLine("Enter any key to quit.");
            Console.ReadLine();

        }

        static void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
        {
            switch (e.Status)
            {
                case GeoPositionStatus.Initializing:
                    Console.WriteLine("Working on location fix");
                    break;

                case GeoPositionStatus.Ready:
                    Console.WriteLine("Have location");
                    break;

                case GeoPositionStatus.NoData:
                    Console.WriteLine("No data");
                    break;

                case GeoPositionStatus.Disabled:
                    Console.WriteLine("Disabled");
                    break;
            }
        }

    }
}

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2016 Microsoft