thread-abort-migration

Migrates .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill thread-abort-migration-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: thread-abort-migration
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/thread-abort-migration
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill thread-abort-migration-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Thread.Abort throws PlatformNotSupportedException in .NET 6+, breaking legacy .NET Framework code that relies on forcible thread termination. This Skill guides the migration of Thread.Abort, ThreadAbortException, Thread.ResetAbort, and Thread.Interrupt usage to the cooperative CancellationToken model required by modern .NET. ## Core Features & Use Cases - Pattern Classification: Inventories all thread-termination APIs and classifies each usage into patterns like cancellable work loops, timeout enforcement, blocking call interruption, and ASP.NET request termination. - Pattern-Specific Replacements: Applies the correct modern replacement for each pattern, such as CancellationTokenSource.CancelAfter for timeouts or WaitHandle.WaitAny with token.WaitHandle for blocking calls. - ASP.NET Migration: Replaces Response.End and Response.Redirect(url, true), which internally call Thread.Abort, with early returns and HttpContext.RequestAborted. - Use Case: After retargeting a legacy ASP.NET application to net8.0, you hit SYSLIB0006 warnings and PlatformNotSupportedException at runtime. Use this Skill to systematically replace every Thread.Abort call site with cooperative cancellation and verify the build is clean. ## Quick Start Migrate all Thread.Abort and ThreadAbortException usage in my .NET Framework project to CancellationToken-based cooperative cancellation targeting net8.0.

Frequently Asked Questions about thread-abort-migration

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

FAQPage Schema
How do I replace Thread.Abort in .NET 6 or later?

Replace Thread.Abort with cooperative cancellation using CancellationToken. Pass a token into the worker, check it with ThrowIfCancellationRequested at safe points, and call CancellationTokenSource.Cancel instead of Abort.

How to fix PlatformNotSupportedException from Thread.Abort after upgrading to .NET 8?

The exception occurs because Thread.Abort is unsupported in modern .NET. Inventory all abort call sites, classify each by intent (work loop, timeout, blocking call), and migrate each to the matching CancellationToken pattern.

What replaces Response.End in ASP.NET Core?

Remove Response.End entirely and simply return from the action method. For long-running request work, use HttpContext.RequestAborted as the cancellation token instead of relying on thread termination.

Does CancellationToken interrupt Thread.Sleep or blocking socket calls?

No, CancellationToken is cooperative and cannot interrupt blocking synchronous calls. Replace Thread.Sleep(ms) with token.WaitHandle.WaitOne(ms) or Task.Delay(ms, token), and use async I/O overloads that accept a token.

When should I not migrate Thread.Abort usage?

Skip migration if the project stays on .NET Framework, if the abort lives in a third-party library you do not control, or if the code only uses Thread.Join, Sleep, or Start, which work identically in modern .NET.

How do I kill code that cannot accept a CancellationToken?

Move uncooperative work, such as third-party libraries or native calls, into a separate child process. Communicate over stdin/stdout or IPC and call Process.Kill when a timeout expires.