Save and Load image from Isolated Storage (Windows Phone)
===

I have found a very usefull class on this link: [images caching][1] - that help me to make logic for caching images. But in my case I have this:


   

     private void DetailView_SelectionChanged(object sender, SelectionChangedEventArgs e)
                {
                                       SaveAndLoadImage(feedItem);
                       
                    
                }


And in this method I save and load image from isolated storage. But I can't load file imidiately because of some permission. How can I correct my logic to save and load images immediately?

     public void SaveAndLoadImage(MediaItemViewModel curItem)
            {
                string url = string.Empty;
                if (!string.IsNullOrEmpty(curItem.ThumbUrl))
                {
                    url = curItem.ThumbUrl;
                }
                if ((string.IsNullOrEmpty(curItem.ThumbUrl)) && (!string.IsNullOrEmpty(curItem.MediaUrl)))
                {
                    url = curItem.MediaUrl;
                }
                if ((!string.IsNullOrEmpty(url)) && (CacheImageFile.GetInstance().IsOnStorage(new Uri(url)) == false))
                {
                    CacheImageFile.DownloadFromWeb(new Uri(url));
    
                }
                if ((!string.IsNullOrEmpty(url)) && (CacheImageFile.GetInstance().IsOnStorage(new Uri(url))))
                {
                    curItem.ImageSource = CacheImageFile.ExtractFromLocalStorage(new Uri(url)) as BitmapImage;
                }
            }



  [1]: https://gist.github.com/2688372#file_cache_image_file_converter.cs%20%20images%20caching