【发布时间】:2014-06-29 06:19:55
【问题描述】:
当前我使用此代码获取 GPS:
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.Default;
geolocator.DesiredAccuracyInMeters = 50;
try
{
Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromSeconds(120), TimeSpan.FromSeconds(30));
MyCoordinate = new GeoCoordinate(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude);
}
catch (Exception ex)
{
if (ex.Message.Contains("This operation returned because the timeout period expired."))
{
MessageBox.Show("GPS is taking too long too complete. Pleaes try again.");
this.SetProgressIndicator(false);
RadBusyIndicator.IsRunning = false;
return;
}
else
{
this.SetProgressIndicator(false);
RadBusyIndicator.IsRunning = false;
return;
}
};
但它总是需要很长时间才能完成,如您所见,我将超时设置为 30 秒但不知道为什么 超过 30 秒时不显示超时异常。 我被困在这个问题上。有人知道吗?
【问题讨论】:
-
您正在发生什么?
-
@RowlandShaw 一百台设备正在使用我的应用程序和这些获取 GPS 的代码,但其中 10% 的设备警告我,尽管我设置了超时时间(30 秒),但获取 GPS 需要很长时间。谢谢
标签: c# windows-phone-8 gps geolocation location