Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GeoCoordinateWatcher.Start Method ()

.NET Framework (current version)

Initiate the acquisition of data from the current location provider. This method enables PositionChanged events and allows access to the Position property.

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

public void Start()

Calling this method will initiate the acquisition of data from the current location provider. The current location provider is selected based on factors such as the age and accuracy of the data from all providers, the accuracy requested by the application or applications, and the power consumption and performance impact associated with the location provider. The current location provider might change over time, for instance, when a GPS device loses its satellite signal indoors and a Wi-Fi triangulation provider becomes the most accurate provider on the computer.

If the current prioritized location provider does not have data when the Start method is called, it will start to acquire data. If the permissions have been granted to the client when the data becomes available, data can be accessed synchronously, and will be delivered asynchronously if events are being handled.

If the Windows 7 Sensor and Location platform is disabled when Start is called, Start will immediately return, PositionChanged events will not be raised, and the location returned by the Location property of Position will contain Unknown.

If the current prioritized location provider does have data, it will be available synchronously immediately, and will be delivered asynchronously if events are being handled.

If the calling application does not have permissions to access data from a location provider, the user will be prompted with a dialog box to either grant or deny permission. The dialog box will be modeless.

The following program handles the first location update that occurs after Start is called.

using System;
using System.Device.Location;

namespace GetLocationDataUpdateOnce
    class Program
        static void Main(string[] args)
            CLocation myLocation = new CLocation();
            Console.WriteLine("Enter any key to quit.");
        class CLocation
            GeoCoordinateWatcher watcher;

            public void GetLocationDataEvent()
                this.watcher = new GeoCoordinateWatcher();
                this.watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

            void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
                PrintPosition(e.Position.Location.Latitude, e.Position.Location.Longitude);
                // Stop receiving updates after the first one.

            void PrintPosition(double Latitude, double Longitude)
                Console.WriteLine("Latitude: {0}, Longitude {1}", Latitude, Longitude);

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2017 Microsoft