Skip to content

Instantly share code, notes, and snippets.

@numa08
Created August 26, 2012 08:58
Show Gist options
  • Save numa08/3476397 to your computer and use it in GitHub Desktop.
Save numa08/3476397 to your computer and use it in GitHub Desktop.
Rxを使って、LocationChangedイベントを捕まえる --泣きながらC# ref: http://qiita.com/items/e9f61340f3de7698c804
var geoWatcher = new GeoCoordinateWatcher();
Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(geoWatcher, "PositionChanged").
ObserveOnDispatcher().
Select(ev => ev.EventArgs.Position.Location).
Take(1).
Subscribe(location => Debug.WriteLine(location.Longitude.ToString()), () => { Debug.WriteLine("completed"); geoWatcher.Stop(); });
geoWatcher.Start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment