private void LoadPlaceList(GeolocationResult result) { Func<int> func = delegate { PlaceList lPlaceList = new PlaceList (); if (result.Position != null) { lPlaceList = new PlaceList ( Engine.Instance.PlaceLocator.GetNearbyPlaces ( (float)result.Position.Latitude, (float)result.Position.Longitude)); } this.BeginInvokeOnMainThread (delegate { if (lPlaceList.Count > 0) { PlaceList = lPlaceList; TableView.ReloadData (); BusyView.Busy = false; } else ShowLocatinError (lPlaceList, result); }); return 0; }; func.BeginInvoke (null, null); }
public GeolocationResult GetLocation() { ManualResetEvent waitToComplete = new ManualResetEvent (false); GeolocationResult result = null; // Not getting the right results if not on main thread MonoTouch.Foundation.NSObject obj = new MonoTouch.Foundation.NSObject (); obj.InvokeOnMainThread (delegate { Task<Position> task = GetTask (); task.ContinueWith (t => { result = new GeolocationResult (_geolocator, t); waitToComplete.Set (); }, _scheduler); }); waitToComplete.WaitOne (); return result; }
protected void ShowLocatinError(PlaceList placeList, GeolocationResult result) { string message; if (result.Canceled) message = "The location request timed out."; else if (result.GeolocationNotAvailable) message = "Location services are not available on this device."; else if (result.GeolocationDisabled) message = "Location services are not enabled for the Evolve application."; else message = "Did not find any places near your location."; BusyView.Busy = false; UIAlertView alertNew = new UIAlertView ("Error", message, null, "Close", null); alertNew.Show (); }