ResolveAddressCompletedEventArgs 类

定义

ResolveAddressCompleted 事件提供数据。

public ref class ResolveAddressCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class ResolveAddressCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type ResolveAddressCompletedEventArgs = class
    inherit AsyncCompletedEventArgs
Public Class ResolveAddressCompletedEventArgs
Inherits AsyncCompletedEventArgs
继承
ResolveAddressCompletedEventArgs

示例

以下示例演示如何使用 ResolveAddressCompletedEventArgs

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.");
    }
}

Public Sub ResolveCivicAddressAsync()
    Dim watcher As GeoCoordinateWatcher
    watcher = New System.Device.Location.GeoCoordinateWatcher(GeoPositionAccuracy.High)
    Dim started As Boolean = False
    watcher.MovementThreshold = 1.0     'set to one meter
    started = watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))
    If started Then
        Dim resolver As CivicAddressResolver = New CivicAddressResolver()
        AddHandler resolver.ResolveAddressCompleted, AddressOf resolver_ResolveAddressCompleted
        If Not watcher.Position.Location.IsUnknown Then
            resolver.ResolveAddressAsync(watcher.Position.Location)
        End If
    End If

    watcher.Start()

End Sub

Sub resolver_ResolveAddressCompleted(ByVal sender As Object, ByVal e As ResolveAddressCompletedEventArgs)
    If Not e.Address.IsUnknown Then
        Console.WriteLine("Country: {0}, Zip: {1}",
                       e.Address.CountryRegion,
                       e.Address.PostalCode)
    Else
        Console.WriteLine("Unknown address.")
    End If
End Sub

构造函数

ResolveAddressCompletedEventArgs(CivicAddress, Exception, Boolean, Object)

初始化 ResolveAddressCompletedEventArgs 的新实例。

属性

Address

获取与 CivicAddress 事件关联的 ResolveAddressCompleted

Cancelled

获取一个值,该值指示异步操作是否已被取消。

(继承自 AsyncCompletedEventArgs)
Error

获取一个值,该值指示异步操作期间发生的错误。

(继承自 AsyncCompletedEventArgs)
UserState

获取异步任务的唯一标识符。

(继承自 AsyncCompletedEventArgs)

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
RaiseExceptionIfNecessary()

如果异步操作失败,则引发用户提供的异常。

(继承自 AsyncCompletedEventArgs)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于