in Backend/src/System.Device/Location/GeoCoordinateWatcherInternal.cs [504:567]
private void HandleLocationStatusChangedEvent(ReportStatus newStatus)
{
lock (this.InternalSyncObject)
{
//
// If we are registered for civic address reports and a latlong provider
// has become available, then unregister for civic address reports
//
if (m_civicAddrRegistered && m_latLongStatus != ReportStatus.NotSupported)
{
if (m_civicAddrRegistered)
{
Guid reportType = LocationReportKey.CivicAddressReport;
if (m_location.UnregisterForReport(ref reportType) == 0)
{
m_civicAddrRegistered = false;
}
}
}
}
GeoPositionStatus prevStatus = Status;
//
// Update current status
//
ReportStatus status = (ReportStatus.NotSupported != m_latLongStatus) ? m_latLongStatus : m_civicAddrStatus;
m_curStatus = m_geoStatusMap[(int)status];
ChangePermissionFromReportStatus(status);
if (IsStarted)
{
//
// If the reported status has changed, send a status change event
//
if (prevStatus != Status)
{
OnPositionStatusChanged(new GeoPositionStatusChangedEventArgs(Status));
//
// If we have location data and have held off sending it until the
// status becomes ready, send the location event now
//
if (GeoPositionStatus.Ready == Status && m_eventPending)
{
m_eventPending = false;
OnPositionChanged(new GeoPositionChangedEventArgs<GeoCoordinate>(m_position));
}
//
// If switching to ready from a permission denied state, then the sensor may not
// send a location changed event. So start a worker thread to get it via a
// synchronous request for current data.
// (Note: Check m_curStatus rather than Status because Status won't be Ready
// if there is no location data.)
//
if (m_curStatus == GeoPositionStatus.Ready)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.GetLocationData), null);
}
}
}
}