private static void PlayAnimation(ImageView control, ISelfDisposingAnimatedBitmapDrawable drawable)
        {
            lock (_runningAnimations)
            {
                var hashCode = control.GetHashCode();

                var timer = new HighResolutionTimer <ISelfDisposingAnimatedBitmapDrawable>(drawable, async(t, bitmap) =>
                {
                    try
                    {
                        try
                        {
                            if (control == null || control.Handle == IntPtr.Zero ||
                                !drawable.IsValidAndHasValidBitmap())
                            {
                                StopAnimation(control);
                                return;
                            }

                            await ImageService.Instance.Config.MainThreadDispatcher.PostAsync(() =>
                            {
                                if (control == null || control.Handle == IntPtr.Zero ||
                                    !drawable.IsValidAndHasValidBitmap())
                                {
                                    StopAnimation(control);
                                    return;
                                }

                                control.SetImageBitmap(bitmap);
                            });
                        }
                        catch (ObjectDisposedException)
                        {
                            StopAnimation(control);
                        }
                    }
                    catch (Exception ex)
                    {
                        ImageService.Instance.Config.Logger.Error("GIF", ex);
                    }
                })
                {
                    DelayOffset = -2
                };

                _runningAnimations.Add(control, timer);

                timer.Start();
            }
        }
 public HighResolutionTimer(ISelfDisposingAnimatedBitmapDrawable animatedDrawable, Func <HighResolutionTimer <TImageContainer>, Bitmap, Task> action)
 {
     AnimatedDrawable = animatedDrawable;
     _action          = action;
 }