Created
August 26, 2012 08:58
-
-
Save numa08/3476397 to your computer and use it in GitHub Desktop.
Rxを使って、LocationChangedイベントを捕まえる --泣きながらC# ref: http://qiita.com/items/e9f61340f3de7698c804
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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