Condividi tramite


GeoCoordinateWatcher.StatusChanged Evento

Definizione

Indica che lo stato dell'oggetto GeoCoordinateWatcher è cambiato.

public:
 event EventHandler<System::Device::Location::GeoPositionStatusChangedEventArgs ^> ^ StatusChanged;
public event EventHandler<System.Device.Location.GeoPositionStatusChangedEventArgs> StatusChanged;
member this.StatusChanged : EventHandler<System.Device.Location.GeoPositionStatusChangedEventArgs> 
Public Custom Event StatusChanged As EventHandler(Of GeoPositionStatusChangedEventArgs) 
Public Event StatusChanged As EventHandler(Of GeoPositionStatusChangedEventArgs) 

Tipo evento

Implementazioni

Esempio

Nell'esempio seguente viene illustrato come gestire StatusChanged gli eventi.

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

Commenti

L'evento StatusChanged viene generato sullo stesso thread in cui è stato creato l'oggetto GeoCoordinateWatcher .

Si applica a