Skip to content

ImageAnimator.StopAnimate (on Unix) could throw PNSE #39405

Description

@jeffhandley

With dotnet/designs#139 and #39269, we are marking Thread.Abort() as Obsolete because it unconditionally throws PlatformNotSupportedException. The tests for the PR turned up that ImageAnimator.Unix.cs uses Thread.Abort() inside StopAnimate.

        public static void StopAnimate(Image image, EventHandler onFrameChangedHandler)
        {
            if (image == null)
                return;

            if (ht.ContainsKey(image))
            {
                AnimateEventArgs evtArgs = (AnimateEventArgs)ht[image]!;
                evtArgs.RunThread!.Abort();
                ht.Remove(image);
            }
        }

I am going to put a #pragma warning disable around the Thread.Abort() call, but this code would be unexpectedly throwing PNSE right now, which means it's either dead code or there's a lurking bug that no one has reported.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions