CivicAddressResolver.ResolveAddressCompleted Event

.NET Framework (current version)
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Occurs when the address resolution that was initiated by a call to ResolveAddressAsync completes.

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

public event EventHandler<ResolveAddressCompletedEventArgs> ResolveAddressCompleted

The following program shows how to call ResolveAddressAsync to resolve a civic address asynchronously.

using System;
using System.Device.Location;
namespace ResolveAddressSync
{
    class Program
    {
        public static void Main(string[] args)
        {
            ResolveAddressAsync();
        }
        static void ResolveAddressAsync()
        {
            GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            bool started = false;
            watcher.MovementThreshold = 1.0; // set to one meter
            started = watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));

            if (started)
            {
                CivicAddressResolver resolver = new CivicAddressResolver();

                resolver.ResolveAddressCompleted += new EventHandler<ResolveAddressCompletedEventArgs>(resolver_ResolveAddressCompleted);

                if (watcher.Position.Location.IsUnknown == false)
                {
                    resolver.ResolveAddressAsync(watcher.Position.Location);
                }
            }

        }

        static void resolver_ResolveAddressCompleted(object sender, ResolveAddressCompletedEventArgs e)
        {
            if (!e.Address.IsUnknown)
            {
                Console.WriteLine("Country: {0}, Zip: {1}",
                           e.Address.CountryRegion,
                           e.Address.PostalCode);
            }
            else
            {
                Console.WriteLine("Unknown address.");
            }
        }


    }
}

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