static private OnError ( Image image, |
||
image | Image | |
exception | ||
kind | AnimationErrorKind | |
return | void |
public async void Play() { try { if (!_isStarted) { _cancellationTokenSource = new CancellationTokenSource(); _isStarted = true; if (_timingManager.IsPaused) _timingManager.Resume(); await RunAsync(_cancellationTokenSource.Token); } else if (_timingManager.IsPaused) { _timingManager.Resume(); } } catch (OperationCanceledException) { } catch (Exception ex) { // ignore errors that might occur during Dispose if (!_disposing) AnimationBehavior.OnError(_image, ex, AnimationErrorKind.Rendering); } }
private static async void InitAnimationAsync(Image image, Stream stream, RepeatBehavior repeatBehavior, int seqNum) { if (!AnimationBehavior.CheckDesignMode(image, null, stream)) { return; } try { Animator async = await Animator.CreateAsync(image, stream, repeatBehavior); AnimationBehavior.SetAnimatorCore(image, async); if (AnimationBehavior.GetSeqNum((DependencyObject)image) != seqNum) { async.Dispose(); } else { AnimationBehavior.OnLoaded(image); } } catch (Exception ex) { AnimationBehavior.OnError(image, ex, AnimationErrorKind.Loading); } }
public async void Play() { try { if (!this._isStarted) { this._cancellationTokenSource = new CancellationTokenSource(); this._isStarted = true; if (this._timingManager.IsPaused) { this._timingManager.Resume(); } await this.RunAsync(this._cancellationTokenSource.Token); } else { if (!this._timingManager.IsPaused) { return; } this._timingManager.Resume(); } } catch (OperationCanceledException) { } catch (Exception ex) { if (this._disposing) { return; } AnimationBehavior.OnError(this._image, ex, AnimationErrorKind.Rendering); } }
internal async void ShowFirstFrame() { try { await RenderFrameAsync(0, CancellationToken.None); CurrentFrameIndex = 0; _timingManager.Pause(); } catch (Exception ex) { AnimationBehavior.OnError(_image, ex, AnimationErrorKind.Rendering); } }
private static void InitAnimation(Image image) { if (AnimationBehavior.IsLoaded((FrameworkElement)image)) { // ISSUE: method pointer ((FrameworkElement)image).Unloaded += (new RoutedEventHandler(AnimationBehavior.Image_Unloaded)); if (AnimationBehavior._cancellationTokenSource != null) { AnimationBehavior._cancellationTokenSource.Cancel(); AnimationBehavior._cancellationTokenSource.Dispose(); AnimationBehavior._cancellationTokenSource = null; } AnimationBehavior._cancellationTokenSource = new CancellationTokenSource(); int seqNum = AnimationBehavior.GetSeqNum((DependencyObject)image) + 1; AnimationBehavior.SetSeqNum((DependencyObject)image, seqNum); image.Source = (null); AnimationBehavior.ClearAnimatorCore(image); try { Stream sourceStream = AnimationBehavior.GetSourceStream((DependencyObject)image); if (sourceStream != null) { AnimationBehavior.InitAnimationAsync(image, sourceStream, AnimationBehavior.GetRepeatBehavior((DependencyObject)image), seqNum); } else { Uri absoluteUri = AnimationBehavior.GetAbsoluteUri(image); if (!(absoluteUri != null)) { return; } AnimationBehavior.InitAnimationAsync(image, absoluteUri, AnimationBehavior._cancellationTokenSource.Token, AnimationBehavior.GetRepeatBehavior((DependencyObject)image), seqNum); } } catch (Exception ex) { AnimationBehavior.OnError(image, ex, AnimationErrorKind.Loading); } } else { // ISSUE: method pointer ((FrameworkElement)image).Loaded += (new RoutedEventHandler(AnimationBehavior.Image_Loaded)); } }
public async void Play() { _cancellationTokenSource = new CancellationTokenSource(); try { if (!_isStarted) { _isStarted = true; await RunAsync(_cancellationTokenSource.Token); } else if (_timingManager.IsPaused) { _timingManager.Resume(); } } catch (OperationCanceledException) { } catch (Exception ex) { AnimationBehavior.OnError(_image, ex, AnimationErrorKind.Rendering); } }
private static async void InitAnimationAsync(Image image, Uri sourceUri, CancellationToken cancellationToken, RepeatBehavior repeatBehavior, int seqNum) { if (!AnimationBehavior.CheckDesignMode(image, sourceUri, null)) { return; } try { // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged += AnimationBehavior.DownloadProgressChanged; Animator async = await Animator.CreateAsync(image, sourceUri, cancellationToken, repeatBehavior); // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged -= AnimationBehavior.DownloadProgressChanged; if (async == null || AnimationBehavior.GetSeqNum((DependencyObject)image) != seqNum) { if (async == null) { return; } // ISSUE: explicit non-virtual call async.Dispose(); } else { AnimationBehavior.SetAnimatorCore(image, async); AnimationBehavior.OnLoaded(image); } } catch (Exception ex) { // ISSUE: reference to a compiler-generated field Animator.DownloadProgressChanged -= AnimationBehavior.DownloadProgressChanged; AnimationBehavior.OnError(image, ex, AnimationErrorKind.Loading); } }