SYSLIB0006: Thread.Abort is not supported

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+.


Use a CancellationToken to abort processing of a unit of work instead of calling Thread.Abort. The following example illustrates the use of CancellationToken.

void ProcessPendingWorkItemsNew(CancellationToken cancellationToken)
    if (QueryIsMoreWorkPending())
        // If the CancellationToken is marked as "needs to cancel",
        // this will throw the appropriate exception.

        WorkItem work = DequeueWorkItem();

Suppress a warning

If you must use the obsolete APIs, you can suppress the warning in code or in your project file.

To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.

// Disable the warning.
#pragma warning disable SYSLIB0006

// Code that uses obsolete API.
// ...

// Re-enable the warning.
#pragma warning restore SYSLIB0006

To suppress all the SYSLIB0006 warnings in your project, add a <NoWarn> property to your project file.

<Project Sdk="Microsoft.NET.Sdk">

For more information, see Suppress warnings.

See also