0
public static async Task<Position> GetCurrentLocation()
{
try
{
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 100;
if (!locator.IsGeolocationAvailable)
throw new NotSupportedException("Geolocation not available");
if (!locator.IsGeolocationEnabled)
throw new GeolocationException(GeolocationError.PositionUnavailable);
return await locator.GetPositionAsync(timeoutMilliseconds: 100000);
}
catch (Exception ex)
{
//TODO: Add error logging
return null;
}
}
スレッド終了とデバッガ return await locator.GetPositionAsync(timeoutMilliseconds: 100000);
には戻らないが、出力ウィンドウには、正しく位置を示していますが、コードには戻りませんでした。この休憩の理由は何でしょうか?Xamarin.iosのiPhoneのデバイスの現在の場所(住所)
を使用しているので、私はこれがあると思う:
だから、どのような場合には、あなたの方法は終了しますあなたが探しているものhttp://stackoverflow.com/questions/34375413/program-exits-upon-calling-await – Webbies