public async Task MaybeCreateTile(Tuple<string, string, TypedThing<Link>> thing)
{
try
{
//we want to queue up 5 tiles to be created but we only want to replace them at a max of once every 14 mintes
if (_tileCreationDates.Count >= 5 && (DateTime.Now - _tileCreationDates.First()).TotalMinutes < 14)
return;
var linkThing = thing.Item3;
if (linkThing == null)
return;
Uri image = null;
if (thing.Item2 != null)
image = new Uri(thing.Item2);
else if (thing.Item1 != null)
image = new Uri(thing.Item1);
if (_tileCreationDates.Count >= 5)
_tileCreationDates.Dequeue();
_tileCreationDates.Enqueue(DateTime.Now);
await CreateTile(linkThing.Data.Title,
!string.IsNullOrWhiteSpace(thing.Item1) ? new Uri(thing.Item1) : null,
!string.IsNullOrWhiteSpace(thing.Item2) ? new Uri(thing.Item2) : null);
}
catch (Exception)
{
//do nothing its not really that important
}
}