diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Unix.cs index 0bafe3e36be07..4ecbc1036662d 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Unix.cs @@ -179,20 +179,13 @@ public WorkerThread(EventHandler frmChgHandler, AnimateEventArgs aniEvtArgs, int public void LoopHandler() { - try + int n = 0; + while (true) { - int n = 0; - while (true) - { - Thread.Sleep(delay[n++]); - frameChangeHandler(null, animateEventArgs); - if (n == delay.Length) - n = 0; - } - } - catch (ThreadAbortException) - { - Thread.ResetAbort(); // we're going to finish anyway + Thread.Sleep(delay[n++]); + frameChangeHandler(null, animateEventArgs); + if (n == delay.Length) + n = 0; } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs index ba36c3f14fa30..bf85ffe8d78be 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -189,6 +189,7 @@ public void Abort(object? stateInfo) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort); } + [Obsolete(Obsoletions.ThreadAbortMessage, DiagnosticId = Obsoletions.ThreadAbortDiagId, UrlFormat = Obsoletions.SharedUrlFormat)] public static void ResetAbort() { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ThreadAbort); diff --git a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs index 3fe3aea58faf7..bd511d1705471 100644 --- a/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs +++ b/src/libraries/System.Threading.Thread/ref/System.Threading.Thread.cs @@ -77,6 +77,7 @@ public void Join() { } public bool Join(int millisecondsTimeout) { throw null; } public bool Join(System.TimeSpan timeout) { throw null; } public static void MemoryBarrier() { } + [System.ObsoleteAttribute("Thread.ResetAbort is not supported and throws PlatformNotSupportedException.", DiagnosticId = "SYSLIB0006", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] public static void ResetAbort() { } [System.ObsoleteAttribute("Thread.Resume has been deprecated. Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources. https://go.microsoft.com/fwlink/?linkid=14202", false)] public void Resume() { } diff --git a/src/libraries/System.Threading.Thread/tests/ThreadTests.cs b/src/libraries/System.Threading.Thread/tests/ThreadTests.cs index 66d8250f5fea7..cad955cce41a9 100644 --- a/src/libraries/System.Threading.Thread/tests/ThreadTests.cs +++ b/src/libraries/System.Threading.Thread/tests/ThreadTests.cs @@ -732,12 +732,13 @@ public static void AbortSuspendTest() Action verify = () => { -#pragma warning disable SYSLIB0006, 618 // Obsolete: Abort, Suspend, Resume +#pragma warning disable SYSLIB0006, 618 // Obsolete: Abort, Suspend, Resume, ResetAbort Assert.Throws(() => t.Abort()); Assert.Throws(() => t.Abort(t)); + Assert.Throws(() => Thread.ResetAbort()); Assert.Throws(() => t.Suspend()); Assert.Throws(() => t.Resume()); -#pragma warning restore SYSLIB0006, 618 // Obsolete: Abort, Suspend, Resume +#pragma warning restore SYSLIB0006, 618 // Obsolete: Abort, Suspend, Resume, ResetAbort }; verify(); @@ -745,9 +746,7 @@ public static void AbortSuspendTest() verify(); e.Set(); - waitForThread(); - - Assert.Throws(() => Thread.ResetAbort()); + waitForThread(); } private static void VerifyLocalDataSlot(LocalDataStoreSlot slot)