private async void StartRefreshAsync()
{
await Task.Delay(3000).ConfigureAwait(false);
while (true)
{
if (CrossConnectivity.Current.IsConnected)
{
// DispatcherHelper.
// At this time, DispatcherHelper cannot be used in a portable class library. Laurent works on a solution.
// var mapCenter = _localisationService.GetCurrentMapCenter();
contracts.ToList().Where(c => !c.ImageAvailability).AsParallel().ForAll(async (c) =>
{
if (await c.RefreshAsync().ConfigureAwait(false))
{
ContractRefreshed?.Invoke(c, EventArgs.Empty);
}
//var station = c.Stations.FirstOrDefault();
//if(station != null)
//{
// if(mapCenter != null)
// {
// var distance = MapHelper.CalcDistance(mapCenter.Latitude, mapCenter.Longitude, station.Latitude, station.Longitude);
// if (distance > 100)
// {
// Debug.WriteLine("DISTANCE : " + distance + " ...");
// return;
// }
// else
// {
// Debug.WriteLine("DISTANCE : " + distance + " Refresh!");
// if (await c.RefreshAsync().ConfigureAwait(false))
// {
// ContractRefreshed?.Invoke(c, EventArgs.Empty);
// }
// }
// }
// else
// {
// if (await c.RefreshAsync().ConfigureAwait(false))
// {
// ContractRefreshed?.Invoke(c, EventArgs.Empty);
// }
// }
//}
});
}
await Task.Delay(timer).ConfigureAwait(false);
}
}