GeoCoordinateWatcher.Status 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 GeoCoordinateWatcher 的目前狀態。
public:
property System::Device::Location::GeoPositionStatus Status { System::Device::Location::GeoPositionStatus get(); };
public System.Device.Location.GeoPositionStatus Status { get; }
member this.Status : System.Device.Location.GeoPositionStatus
Public ReadOnly Property Status As GeoPositionStatus
屬性值
GeoPositionStatus,表示 GeoCoordinateWatcher 是否有提供資料。
實作
範例
下列範例會處理 StatusChanged 事件,並根據 列印訊息 Status。
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;
}
}
}
}
Imports System.Device.Location
Module GetLocationEvent
Sub ShowStatusUpdates()
Dim Watcher As GeoCoordinateWatcher
Watcher = New GeoCoordinateWatcher()
watcher.Start()
AddHandler Watcher.StatusChanged, AddressOf watcher_StatusChanged
Console.WriteLine("Enter any key to quit.")
Console.ReadLine()
End Sub
Sub watcher_StatusChanged(ByVal sender As Object, ByVal e As GeoPositionStatusChangedEventArgs)
Select Case e.Status
Case GeoPositionStatus.Initializing
Console.WriteLine("Working on location fix")
Case GeoPositionStatus.Ready
Console.WriteLine("Have location")
Case GeoPositionStatus.NoData
Console.WriteLine("No data")
Case GeoPositionStatus.Disabled
Console.WriteLine("Disabled")
End Select
End Sub
Public Sub Main()
ShowStatusUpdates()
End Sub
End Module