in Backend/src/System.Device/Location/LocationProviderInternal.cs [456:510]
private void HandleLocationStatusChangedEvent(ReportStatus newStatus)
{
//
// 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;
}
}
}
GeoLocationStatus prevStatus = Status;
//
// Update the current status
//
ReportStatus status = (ReportStatus.NotSupported != m_latLongStatus) ? m_latLongStatus : m_civicAddrStatus;
m_curStatus = m_geoStatusMap[(int)status];
//
// If the reported status has changed, send a status change event
//
if (prevStatus != Status)
{
OnStatusChanged(new GeoLocationStatusChangedEventArgs(Status));
//
// If we have location data and have held off sending it until the
// status becomes ready, send the location event now
//
if (GeoLocationStatus.Ready == Status && m_eventPending)
{
m_eventPending = false;
OnLocationChanged(new GeoLocationChangedEventArgs(m_curLocation));
}
//
// 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 (prevStatus == GeoLocationStatus.NoPermissions && m_curStatus == GeoLocationStatus.Ready)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(this.GetLocationData), null);
}
}
}