Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chamando método Async no OnNavegatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
LoadCity();
await StartGeoLocation();
base.OnNavigatedTo(e);
}
private async Task StartGeoLocation()
{
try
{
City city = new City();
if (city.GetCurrencyCity() == null)
{
//TODO Preciso verificar o load da localizacao
Geolocator geolocator = new Geolocator();
//geolocator.DesiredAccuracyInMeters = 50;
geolocator.DesiredAccuracy = PositionAccuracy.High;
Geoposition geoposition = await geolocator.GetGeopositionAsync(
maximumAge: TimeSpan.FromMinutes(5),
timeout: TimeSpan.FromSeconds(10)
);
SetCurrentLocation(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
}
}
catch (Exception ErroStartLocation)
{
System.Diagnostics.Debug.WriteLine("Error load");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.