Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created February 25, 2014 11:45
Show Gist options
  • Save guilhermecarvalhocarneiro/9207435 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/9207435 to your computer and use it in GitHub Desktop.
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