예제 #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);
     }
 }
예제 #2
0
 private void SetImage(WeakReference <BitmapSource> weakReference, BitmapSource value, [CallerMemberName] string propertyName = null)
 {
     BitmapSourceStrongReferenceCache.RefreshReference(value);
     weakReference.SetTarget(value);
     OnPropertyChanged(propertyName);
 }