partial void OnSourceChangedPartial(ImageSource newValue, ImageSource oldValue) { if (newValue == null || !newValue.HasSource()) { SetImage(null, failIfNull: false); oldValue?.Dispose(); _imageScheduler.Disposable = null; } else if (newValue.ImageData != null) { SetImage(newValue.ImageData); oldValue?.Dispose(); _imageScheduler.Disposable = null; } else { SetImage(null, failIfNull: false); oldValue?.Dispose(); _imageScheduler.Disposable = CoreDispatcher.Main.RunAsync( CoreDispatcherPriority.Normal, async ct => { var image = await Task.Run(async() => await newValue.Open(ct)); if (ct.IsCancellationRequested) { return; } SetImage(image); }); } }
partial void OnSourceChangedPartial(ImageSource newValue, ImageSource oldValue) { oldValue?.Dispose(); _imageSourceChanged = true; _onImageLoaded?.Invoke(); return; }
partial void OnSourceChangedPartial(ImageSource newValue, ImageSource oldValue) { if (newValue == null || !newValue.HasSource()) { SetImage(null, failIfNull: false); oldValue?.Dispose(); _imageScheduler.Disposable = null; } else if (newValue.TryOpenSync(out var image)) { SetImage(image); oldValue?.Dispose(); _imageScheduler.Disposable = null; } else { SetImage(null, failIfNull: false); oldValue?.Dispose(); OpenImageAsync(newValue); } }