Export (0) Print
Expand All

GeoLocationProvider.LocationChanged Event

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Occurs when either the Address or Coordinate properties for the current location have changed.

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

public event EventHandler<GeoLocationChangedEventArgs> LocationChanged

NoteNote

In versions of Windows other than Windows 7, all System.Device.Location objects that have constructors can be created, but the Status property always has the value Disabled, the Location property always returns Unknown, and no location events occur.

The following code checks for location updates continuously by subscribing to the LocationChanged event.

using (var provider = new GeoLocationProvider()) {

provider.LocationChanged += (sender, e) => {

var coordinate = e.Location.Coordinate;

Console.WriteLine("Lat: {0}, Long: {1}", coordinate.Latitude,

coordinate.Longitude);

};

provider.Start();

Console.ReadLine();

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4
Show:
© 2014 Microsoft