Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYSLIB0006: Thread.Abort is not supported #407

Open
jozefizso opened this issue Feb 16, 2024 · 0 comments
Open

SYSLIB0006: Thread.Abort is not supported #407

jozefizso opened this issue Feb 16, 2024 · 0 comments
Milestone

Comments

@jozefizso
Copy link
Member

The following APIs are marked obsolete, starting in .NET 5. Use of these APIs generates warning SYSLIB0006 at compile time and a PlatformNotSupportedException at run time.

When you call Thread.Abort to abort a thread other than the current thread, you don't know what code has executed or failed to execute when the ThreadAbortException is thrown. You also cannot be certain of the state of your application or any application and user state that it's responsible for preserving. For example, calling Thread.Abort may prevent the execution of static constructors or the release of managed or unmanaged resources. For this reason, Thread.Abort always throws a PlatformNotSupportedException on .NET Core and .NET 5+.

Workarounds

Use a CancellationToken to abort processing of a unit of work instead of calling Thread.Abort.

https://learn.microsoft.com/en-us/dotnet/fundamentals/syslib-diagnostics/syslib0006

@jozefizso jozefizso added this to the 2.0 milestone Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant