private async Task CreateCategoryItem(ImageMetaData imageMetaData)
 {
     Func<Task<IBitmap>> lazyImageFactory = () => downloadManager.DownloadImage(imageMetaData.imageThumbnail);
     var category = new CategoryItem(imageMetaData.imageUrl, imageMetaData.Category, lazyImageFactory);
     CategoryItems.Add(category);
     await category.LoadImage();
 }
 private ImageMetaData CreateImageMetaData(rssChannelItem rssChannelItem)
 {
     var html = rssChannelItem.description;
     var imageUrl = GetImageUrl(html);
     var imageMetaData = new ImageMetaData(imageUrl) { Category = rssChannelItem.title };
     return imageMetaData;
 }
        public async Task<BitmapImage> GetImage(ImageMetaData imageMetaData, bool getThumbnail = false)
        {
            var imageStream = await GetImageStream(imageMetaData);

            //BECAUSE WP8 SAID SO
            BitmapImage image = new BitmapImage();
            image.SetSource(imageStream);
            return image;
        }
        public async Task<Stream> GetImageStream(ImageMetaData imageMetaData, bool getThumbnail = false)
        {
            byte[] imageBytes = null;
            bool shouldGet = false;
            string url = getThumbnail ? imageMetaData.imageThumbnail : imageMetaData.imageUrl;
            try
            {
                imageBytes = await BlobCache.LocalMachine.GetAsync(url);
            }
            catch (Exception e)
            {
                shouldGet = true;
            }
            if (shouldGet)
            {
                imageBytes = await queue.Enqueue(1, async () =>
                {
                    using (var client = new HttpClient())
                    {
                        byte[] tempimageBytes = null;
                        try
                        {
                            tempimageBytes = await client.GetByteArrayAsync(url);
                            await BlobCache.LocalMachine.Insert(url, tempimageBytes);
                        }
                        catch (Exception e)
                        {
                            //MessageBox.Show("Please check your network connection");
                        }
                        return tempimageBytes;
                    }
                });
            }
            var imageStream = new MemoryStream(imageBytes);

            return imageStream;
        }