I have an area in my wpf project that should display an image by link. The image on the link changes with a certain frequency. My code:
string path1 = @"";//link from image
image_1.Source = null;
GC.Collect();
BitmapImage bi1 = new BitmapImage();
bi1.BeginInit();
bi1.CacheOption = BitmapCacheOption.OnLoad;
bi1.UriSource = new Uri(path1);
bi1.EndInit();
bi1.Freeze();
image_1.Source = bi1;
GC.Collect();
delete_old(path1);//delete file
This all happens in a loop and in the moment between image_1.Source = null and assigning a new value, the image disappears for a while, which looks terrible.
I would like the picture to change from the old to the new one without a blank screen, I did not find other ways to implement it. If I don't set the path to null, then the image just doesn't change.