目前我使用此代碼來獲得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需要太長的時間。 謝謝 –