Skip to content

Instantly share code, notes, and snippets.

@mr5z
Created October 6, 2017 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr5z/bcc355ffee505d27e2c34e8edde1c328 to your computer and use it in GitHub Desktop.
Save mr5z/bcc355ffee505d27e2c34e8edde1c328 to your computer and use it in GitHub Desktop.
void LocationChanged(object sender, PositionEventArgs e)
{
if (stopWatch == null) {
stopWatch = Stopwatch.StartNew();
}
var position = e.Position;
if (UnixTimeStamp > previousUpdateTime + MinUpdateTime) {
stopWatch.Stop();
Log("location: ({0}, {1}), lapsed time: {2}", position.Latitude, position.Longitude, stopWatch.ElapsedMilliseconds);
previousUpdateTime = UnixTimeStamp;
}
else {
skippedLocationsCount++;
Log("location skipped count: {0}", skippedLocationsCount);
if (!stopWatch.IsRunning) {
stopWatch.Restart();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment