private static GetSeqNum ( DependencyObject obj ) : int | ||
obj | DependencyObject | |
Результат | int |
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); } }
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)); } }
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); } }