Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin Mobile Geolocator

Hey there,

I've been using Xamarin Mobile in order to retrieve the current location of the user. Everything works as expected, but the code uses a hardcoded time out (see code below). Does the Xamarin Mobile api support an event when the location is found instead of using a hard coded timeout?

It's a bit useless using a 5000 milisecond timeout when the location is already found after 2000 miliseconds.

var locator = new Geolocator { DesiredAccuracy = 50 }; // new Geolocator (this) { ... }; on Android locator.GetPositionAsync (timeout: 5000).ContinueWith (t => { CurrentPosition = new ParseGeoPoint() { Longitude = t.Result.Longitude, Latitude = t.Result.Latitude }; }, TaskScheduler.FromCurrentSynchronizationContext());


  • prashantvcprashantvc USXamarin Team Xamurai

    @Mittchel IIRC the GetPositionAsync method does not wait till the timeout to invoke callback method if location information available immediately or before the time out period.

Sign In or Register to comment.