Click here to Skip to main content
15,893,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, at first I introduce myself, I'm Martin of Argentina, is the first time I do a query in the forum. I do not write very well in English, so I apologize.

I want to see if it is feasible to help me with a problem I have.
Using C # and Wpf.

When loading an image, the first time that passes here works perfectly, the second longer. As I can clean the variables to be re-run the entire code if you pass a second time.



C#
void LoadImageAsyn(string uri)
               {
                   StatusPrompt.Content = "Descargando";
                   PreviewImage.Source = null;
                   bindingContext.Image = null;
                   TopContentArea.IsEnabled = false;

                   Uri u = new Uri(uri, UriKind.RelativeOrAbsolute);
                   BitmapImage img = new BitmapImage(u);
                   img.DownloadCompleted += new EventHandler(ImageDownloadCompleted);
                   img.DownloadFailed += new EventHandler<ExceptionEventArgs>(ImageDownloadFailed);
               }




Try to fix it by adding:

img.BeginInit ();
img.CacheOption = BitmapCacheOption.OnLoad;
img.EndInit ();

But tampocome funcinó. I can provide a little of your time and give me guidance on the problem that I present.

From already thank you very much.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900