title: Windows Phone 8.1 location-tracking
body: <p>I want to realize an App that continuously send device's position to a web service. Looking in the documentation, I've found Geolocation class and some articles where position-tracking is discussed:</p>
  
  <ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247548%28v=vs.105%29.aspx" rel="nofollow noreferrer">How to continuously track the phone's location for Windows Phone 8</a></li>
  <li><a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662935%28v=vs.105%29.aspx" rel="nofollow noreferrer">How to run location-tracking apps in the background for Windows Phone 8</a></li>
  </ul>
  
  <p>Implementing both example projects discussed in these articles, I've noticed that the geolocator_PositionChanged() event is not fired at every position update. There is a delay (about 10/15 minutes) between 2 execution of the event. The strange thing is that this happens even when the App executes in foreground (not only in background). I'm using Windows Phone emulator.</p>
  
  <p>In my App I have a map control where I need to show user's position and, so, I need that the geolocator_PositionChanged() event be correctly fired for each position update, without delays.</p>
  
  <p>1) How can I track (without delays) the device's position using Geolocator class?</p>
  
  <p>Searching over the network, I've found the GeoCoordinateWatcher class, that provides continuosly position-tracking of the device. This is the code:</p>
  
  <pre><code>public MainPage()
  {
      InitializeComponent();
      this.GetCoordinate();
  }
  
  private void GetCoordinate()
  {
      var watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
      {
          MovementThreshold = 1
      };
      watcher.PositionChanged += this.watcher_PositionChanged;
      watcher.Start();
  }
  
  private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs&lt;GeoCoordinate&gt; e)
  {
      //Get position data
      var pos = e.Position.Location;
      //Update mypos object
      mypos.update(pos.Latitude, pos.Longitude);
      //Update data on the main interface
      MainMap.SetView(mypos.getCoordinate(), MainMap.ZoomLevel, MapAnimationKind.Parabolic);
  }
  </code></pre>
  
  <p>It works: watcher_PositionChanged() event is fired without delays.</p>
  
  <p>2) Why the GeoCoordinateWatcher does not have delays? What is the difference between GeoCoordinateWatcher class and Geolocator class?</p>
  
  <p>Finally, the App should send device's position to the web service even when it is not active. So, I need a background task. As proposed <a href="https://stackoverflow.com/questions/24235082/execute-a-windows-phone-8-1-application-after-deactivation">here</a> by Romasz, I can use Geolocator class with some limitations.</p>
  
  <p>3) Can I use GeoCoordinateWhatcher in background? If yes, how?</p>
  
  <p>My goal is to realize a position-tracking App without delays, that even works in background. What is the best way to do this? The App should track the device's position and continuously update the web service (even when in background).  How can I do this? What is the best approach? I know about the Windows Phone Apps lifecycle and I can accept some limitations for the background execution. What are the background limits?</p>