public async Task UpdateTile(Action callback = null) { try { var source = new Shane.Church.StirlingBirthday.Core.WP.Data.PhoneBirthdaySource(); var contacts = await source.GetAllEntriesAsync(); var tileContacts = new List <BirthdayContact>(); if (contacts.Any()) { tileContacts = contacts.OrderBy(it => it.DaysUntil).Take(3).ToList(); } var count = 0; contacts = null; source = null; System.GC.Collect(); System.GC.WaitForPendingFinalizers(); System.GC.Collect(); UpdateTileSynchronous(tileContacts, count, callback); } catch (Exception ex) { DebugUtility.SaveDiagnosticException(ex); } }
public async Task SaveUpcomingImages() { var source = new Shane.Church.StirlingBirthday.Core.WP.Data.PhoneBirthdaySource(); var contacts = await source.GetFilteredEntriesAsync(c => c.DaysUntil <= DaysToBuild, false); try { List <string> filenames = new List <string>(); foreach (var c in contacts) { var picture = await source.GetContactPictureAsync(c.DisplayName); BirthdayTileFrontViewModel model = new BirthdayTileFrontViewModel(c, picture); MediumTileUserControl mediumTile = new MediumTileUserControl() { DataContext = model }; #if WP8 SmallTileUserControl smallTile = new SmallTileUserControl() { DataContext = model }; WideTileUserControl wideTile = new WideTileUserControl() { DataContext = model }; #endif var mediumPath = string.Format(isoStorePath, model.Name, "m"); filenames.Add(mediumPath); #if WP8 var smallPath = string.Format(isoStorePath, model.Name, "s"); filenames.Add(smallPath); var widePath = string.Format(isoStorePath, model.Name, "w"); filenames.Add(widePath); #endif await Deployment.Current.Dispatcher.InvokeAsync(async() => { await mediumTile.ToTileAsync(mediumPath); #if WP8 await smallTile.ToTileAsync(smallPath); await wideTile.ToTileAsync(widePath); #endif }); } for (int i = 0; i < DaysToBuild; i++) { } CleanUnusedFiles(filenames); } catch (Exception) { } }