,

Sampling the PositionChanged Event with Rx

If the built-in Geolocator class is assigned too low a MovementThreshold value, the event handler for the Geolocator.PositionChanged event may be raised more frequently than needed, which can potentially degrade the performance of your app. The Reactive Extensions (Rx) can eliminate this issue by modulating, or sampling, the event, restricting calls to the PositionChanged event handler to a certain number each second.

Rx is a managed library that has been included as part of the Windows Phone Framework Class Library (FCL). At its essence, Rx allows events to be treated as a data stream. Rx allows you to subscribe to this data stream and to manipulate and filter the data stream before it is handled by your app.

Rx can be thought of as LINQ to Events, and includes all the standard LINQ query operators. Rx provides a convenient mechanism for passing around event streams, which makes working with events easier. It uses the Dispose pattern and the IDisposable interface in conjunction with event subscriptions, and automatically unsubscribes from events, eliminating potential memory leaks.

If you are new to Rx, it is recommended that you learn more about it because it is an invaluable tool when working with an asynchronous programming model. Rx is being used evermore frequently by developers for asynchronous programming. The Windows Phone Toolkit team, for example, used Rx to write reliable, event-based asynchronous tests for many of the Toolkit components.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.102.142