thread-abort-migration

Migrate .NET Framework Thread.Abort code to CancellationToken-based cooperative cancellation.

5.1k|377|Updated Feb 3, 2026
One-click install
npx skills add https://github.com/dotnet/skills --skill thread-abort-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: thread-abort-migration
Source: https://github.com/dotnet/skills/tree/main/plugins/dotnet-upgrade/skills/thread-abort-migration
Command: npx skills add https://github.com/dotnet/skills --skill thread-abort-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps migrate legacy .NET Framework code that relies on Thread.Abort to the cooperative cancellation model required in modern .NET versions, preventing runtime errors and improving application stability.

Core Features & Use Cases

  • Identify Thread.Abort patterns: Detects usage of Thread.Abort, ThreadAbortException, Thread.ResetAbort, and Thread.Interrupt.
  • Guide cooperative cancellation: Provides strategies to replace preemptive thread termination with cooperative cancellation using CancellationToken.
  • Handle ASP.NET specific cases: Addresses migration of Response.End and Response.Redirect(url, true).
  • Use Case: Migrating a .NET Framework application to .NET 8 that uses Thread.Abort for timeouts or cleanup, ensuring it functions correctly without throwing PlatformNotSupportedException.

Quick Start

Use the thread-abort-migration skill to guide the modernization of code that calls Thread.Abort in the 'MyProject.csproj' project.

Frequently Asked Questions about thread-abort-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Thread.Abort to modern .NET without throwing PlatformNotSupportedException?

To migrate Thread.Abort to modern .NET, replace preemptive thread termination with cooperative cancellation using CancellationToken. This prevents PlatformNotSupportedException and improves application stability by allowing threads to safely exit.

What is the best way to replace ThreadAbortException and Thread.ResetAbort in .NET 8?

The best way to replace ThreadAbortException and Thread.ResetAbort is adopting cooperative cancellation. Transition your legacy .NET Framework code to use CancellationToken, ensuring threads monitor the token and exit gracefully instead of relying on forced termination.

How do I handle Response.End and Response.Redirect(url, true) when migrating to modern .NET?

When migrating ASP.NET code to modern .NET, handle Response.End and Response.Redirect(url, true) by replacing their preemptive thread termination behavior with CancellationToken patterns. This ensures safe execution flow without relying on Thread.Abort.

Can I use Thread.Interrupt for cooperative cancellation in modern .NET?

Thread.Interrupt is not the recommended approach for cooperative cancellation in modern .NET. You should replace both Thread.Interrupt and Thread.Abort with CancellationToken to ensure stable, cross-platform thread management and prevent runtime errors.

Why does Thread.Abort cause runtime errors in modern .NET versions?

Thread.Abort causes runtime errors in modern .NET because preemptive thread termination is unsupported, throwing PlatformNotSupportedException. Modern .NET requires cooperative cancellation using CancellationToken to ensure stable state management and safe resource cleanup.