Exemple #1
0
        private Task <IBitmap> LoadImageFromCache(string key, int size)
        {
            // If we don't have the small version of an artwork, resize it, save it and return it.
            // This saves us a bunch of memory at the next startup, because BitmapImage has some
            // kind of memory leak, so the not-resized image hangs around in memory forever.

            string keyWithSize = BlobCacheKeys.GetArtworkKeyWithSize(key, size);

            return(this.LoadImageFromCacheSave(keyWithSize)
                   .Catch <IBitmap, KeyNotFoundException>(ex =>
                                                          this.LoadImageFromCacheSave(key, size)
                                                          .SelectMany(async resized =>
            {
                await this.SaveImageToBlobCacheAsync(key, resized);
                return resized;
            }))
                   .ToTask());
        }