目前我使用此代码来获得GPS:GetGeopositionAsync花费太长时间才能完成
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需要太长的时间。 谢谢 –