Ejemplo n.º 1
0
 private BitmapSource GetOrLoadImage(WeakReference <BitmapSource> weakReference, Func <BitmapSource> reload)
 {
     if (weakReference.TryGetTarget(out BitmapSource strongReference))
     {
         return(strongReference);
     }
     else
     {
         var value = reload();
         BitmapSourceStrongReferenceCache.RefreshReference(value);
         weakReference.SetTarget(value);
         return(value);
     }
 }
Ejemplo n.º 2
0
 private void SetImage(WeakReference <BitmapSource> weakReference, BitmapSource value, [CallerMemberName] string propertyName = null)
 {
     BitmapSourceStrongReferenceCache.RefreshReference(value);
     weakReference.SetTarget(value);
     OnPropertyChanged(propertyName);
 }