Official agent skill

Thread Abort Migration

by dotnet in dotnet/skills

Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET.

OfficialMITAuto-check passed

Install Thread Abort Migration

skills CLI
$ npx skills add dotnet/skills --skill thread-abort-migration -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dotnet/skills thread-abort-migration --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dotnet/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/dotnet-upgrade/skills/thread-abort-migration .claude/skills/thread-abort-migration && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
thread-abort-migration
GitHub stars
5.6k
Used in
1 other repo
Token cost
~3.2k tokens
SKILL.md length
1,350 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET.

  • Works in 5 steps: Inventory all thread termination usage → Classify each usage pattern → Apply the replacement for each pattern → …
  • : modernizing code that calls Thread.Abort
  • SKILL.md covers When to Use, When Not to Use, Inputs and Workflow, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Thread Abort Migration is an agent skill from dotnet/skills, published by the product's own GitHub organization. Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET. USE FOR: modernizing code that calls Thread.Abort, catching ThreadAbortException, replacing Thread.ResetAbort, replacing Thread.Interrupt for thread termination, resolving PlatformNotSupportedException or SYSLIB0006 after retargeting to .NET 6+, migrating ASP.NET Response.End or Response.Redirect(url, true) which internally call Thread.Abort. DO NOT USE FOR: code that only uses Thread.Join, Thread.Sleep, or…

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It works with .NET and ASP.NET Core. The repository describes itself as: Repository for skills to assist AI coding agents with .NET and C. The licence is MIT.

When your agent uses it

  • : modernizing code that calls Thread.Abort
  • Catching ThreadAbortException
  • Replacing Thread.ResetAbort
  • Replacing Thread.Interrupt for thread termination

Example prompts

  • “Use the thread-abort-migration skill to guide migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET”
  • “/thread-abort-migration”

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Inventory all thread termination usage
  2. Classify each usage pattern
  3. Apply the replacement for each pattern
  4. Clean up removed APIs
  5. Verify the migration

What it can do on your machine

Read from SKILL.md and the folder at commit 8d670fa. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Thread Abort Migration loads about 3.2k tokens when it runs. Until then it costs about 198 tokens; SKILL.md has 1,350 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~198
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dotnet/skills at commit 8d670fa, republished under its MIT licence (© dotnet). 1,350 words, ~3,202 tokens.

Download SKILL.mdSave it as .claude/skills/thread-abort-migration/SKILL.md (or your agent's skills folder).
name
thread-abort-migration
description
Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET. USE FOR: modernizing code that calls Thread.Abort, catching ThreadAbortException, replacing Thread.ResetAbort, replacing Thread.Interrupt for thread termination, resolving PlatformNotSupportedException or SYSLIB0006 after retargeting to .NET 6+, migrating ASP.NET Response.End or Response.Redirect(url, true) which internally call Thread.Abort. DO NOT USE FOR: code that only uses Thread.Join, Thread.Sleep, or Thread.Start without any abort, interrupt, or ThreadAbortException usage — these APIs work identically in modern .NET and need no migration. Also not for projects staying on .NET Framework, or Thread.Abort usage inside third-party libraries you do not control.
license
MIT

Thread.Abort Migration

This skill helps an agent migrate .NET Framework code that uses Thread.Abort to the cooperative cancellation model required by modern .NET (6+). Thread.Abort throws PlatformNotSupportedException in modern .NET — there is no way to forcibly terminate a managed thread. The skill identifies the usage pattern first, then applies the correct replacement strategy.

When to Use

  • Migrating a .NET Framework project to .NET 6+ that calls Thread.Abort
  • Replacing ThreadAbortException catch blocks that use control flow or cleanup logic
  • Removing Thread.ResetAbort calls that cancel pending aborts
  • Replacing Thread.Interrupt for waking blocked threads
  • Migrating ASP.NET code that uses Response.End or Response.Redirect(url, true), which internally call Thread.Abort
  • Resolving PlatformNotSupportedException or SYSLIB0006 warnings after a target framework change

When Not to Use

  • The code only uses Thread.Join, Thread.Sleep, or Thread.Start without any abort, interrupt, or ThreadAbortException catch blocks. These APIs work identically in modern .NET — no migration is needed. Stop here and tell the user no migration is required. If you suggest modernization (e.g., Task.Run, Parallel.ForEach), you must explicitly state these are optional improvements unrelated to Thread.Abort migration, and the existing code will compile and run correctly as-is on the target framework.
  • The project will remain on .NET Framework indefinitely
  • The Thread.Abort usage is inside a third-party library you do not control

Inputs

InputRequiredDescription
Source project or solutionYesThe .NET Framework project containing Thread.Abort usage
Target frameworkYesThe modern .NET version to target (e.g., net8.0)
Thread.Abort usage locationsRecommendedFiles or classes that reference Thread.Abort, ThreadAbortException, Thread.ResetAbort, or Thread.Interrupt

Workflow

Commit strategy: Commit after each pattern replacement so the migration is reviewable and bisectable. Group related call sites (e.g., all cancellable work loops) into one commit.

Step 1: Inventory all thread termination usage

Search the codebase for all thread-termination-related APIs:

  • Thread.Abort and thread.Abort() (instance calls)
  • ThreadAbortException in catch blocks
  • Thread.ResetAbort
  • Thread.Interrupt
  • Response.End() (calls Thread.Abort internally in ASP.NET Framework)
  • Response.Redirect(url, true) (the true parameter triggers Thread.Abort)
  • SYSLIB0006 pragma suppressions

Record each usage location and classify the intent behind the abort.

Step 2: Classify each usage pattern

Categorize every usage into one of the following patterns:

PatternDescriptionModern replacement
Cancellable work loopThread running a loop that should stop on demandCancellationToken checked in the loop
Timeout enforcementAborting a thread that exceeds a time limitCancellationTokenSource.CancelAfter or Task.WhenAny with a delay
Blocking call interruptionThread blocked on Sleep, WaitOne, or Join that needs to wake upWaitHandle.WaitAny with CancellationToken.WaitHandle, or async alternatives
ASP.NET request terminationResponse.End or Response.Redirect(url, true)Return from the action method; use HttpContext.RequestAborted
ThreadAbortException as control flowCatch blocks that inspect ThreadAbortException to decide cleanup actionsCatch OperationCanceledException instead, with explicit cleanup
Thread.ResetAbort to continue executionCatching the abort and calling ResetAbort to keep the thread aliveCheck CancellationToken.IsCancellationRequested and decide whether to continue
Uncooperative code terminationKilling a thread running code that cannot be modified to check for cancellationMove the work to a separate process and use Process.Kill

Critical: The fundamental paradigm shift is from preemptive cancellation (the runtime forcibly injects an exception) to cooperative cancellation (the code must voluntarily check for and respond to cancellation requests). Every call site must be evaluated for whether the target code can be modified to cooperate.

Step 3: Apply the replacement for each pattern
  • Cancellable work loop: Add a CancellationToken parameter. Replace the loop condition or add token.ThrowIfCancellationRequested() at safe checkpoints. The caller creates a CancellationTokenSource and calls Cancel() instead of Thread.Abort().
  • Timeout enforcement: Use new CancellationTokenSource(TimeSpan.FromSeconds(n)) or cts.CancelAfter(timeout). Pass the token to the work. For task-based code, use Task.WhenAny(workTask, Task.Delay(timeout, cts.Token)) and cancel the source if the delay wins; cancelling also disposes the delay's internal timer.
  • Blocking call interruption: Replace Thread.Sleep(ms) with Task.Delay(ms, token) or token.WaitHandle.WaitOne(ms). Replace ManualResetEvent.WaitOne() with WaitHandle.WaitAny(new[] { event, token.WaitHandle }).
  • ASP.NET request termination: Remove Response.End() entirely — just return from the method. Replace Response.Redirect(url, true) with Response.Redirect(url) (without the true endResponse parameter) or return a redirect result. In ASP.NET Core, use HttpContext.RequestAborted as the cancellation token for long-running request work.
  • ThreadAbortException as control flow: Replace catch (ThreadAbortException) with catch (OperationCanceledException). Move cleanup logic to finally blocks or CancellationToken.Register callbacks. Do not catch OperationCanceledException and swallow it — let it propagate unless you have a specific recovery action.
  • Thread.ResetAbort to continue execution: Break up "abortable" units of work so that cancellation in a processing loop can continue to the next unit instead of relying on ResetAbort to prevent tearing down the thread. Check token.IsCancellationRequested after each unit and decide whether to continue. Create a new CancellationTokenSource (optionally linked to a parent token) for each new unit of work rather than trying to reset an existing one.
  • Uncooperative code termination: If the code cannot be modified to accept a CancellationToken (e.g., third-party library, native call), move the work to a child process. The host process communicates via stdin/stdout or IPC and calls Process.Kill if a timeout expires.
Show full SKILL.md (552 more words)Show less
Step 4: Clean up removed APIs

After migrating all patterns, remove or replace any remaining references:

Removed APIReplacement
Thread.Abort()CancellationTokenSource.Cancel()
ThreadAbortException catch blocksOperationCanceledException catch blocks
Thread.ResetAbort()Check token.IsCancellationRequested and decide whether to continue
Thread.Interrupt()Signal via CancellationToken or set a ManualResetEventSlim (also obsolete: SYSLIB0046 in .NET 9)
Response.End()Remove the call; return from the method
Response.Redirect(url, true)Response.Redirect(url) without endResponse, or return a redirect result
#pragma warning disable SYSLIB0006Remove after replacing the Thread.Abort call
Step 5: Verify the migration
  1. Build the project targeting the new framework. Confirm zero SYSLIB0006 warnings and no Thread.Abort-related compile errors.
  2. Search the codebase for any remaining references to Thread.Abort, ThreadAbortException, Thread.ResetAbort, or Thread.Interrupt.
  3. Run existing tests. If tests relied on Thread.Abort for cleanup or timeout, update them to use CancellationToken.
  4. For timeout scenarios, verify that work actually stops within a reasonable time after cancellation is requested.
  5. For blocking call scenarios, verify that blocked threads wake up promptly when the token is cancelled.

Validation

  • No references to Thread.Abort remain in the migrated code
  • No ThreadAbortException catch blocks remain
  • No Thread.ResetAbort calls remain
  • No SYSLIB0006 pragma suppressions remain
  • Project builds cleanly against the target framework with no thread-abort-related warnings
  • All cancellable work accepts a CancellationToken parameter
  • Timeout scenarios use CancellationTokenSource.CancelAfter or equivalent
  • Blocking calls use WaitHandle.WaitAny with token.WaitHandle or async alternatives
  • Existing tests pass or have been updated for cooperative cancellation

Common Pitfalls

PitfallSolution
Adding CancellationToken parameter but never checking it in long-running codeInsert token.ThrowIfCancellationRequested() at regular checkpoints in loops and between expensive operations. Cancellation only works if the code cooperates.
Not passing the token through the full call chainEvery async or long-running method in the chain must accept and forward the CancellationToken. If one method in the chain ignores it, cancellation stalls at that point.
Expecting CancellationToken to interrupt blocking synchronous calls like Thread.Sleep or socket.ReceiveThese calls do not check the token. Replace Thread.Sleep(ms) with token.WaitHandle.WaitOne(ms). Replace synchronous I/O with async overloads that accept a CancellationToken.
Catching OperationCanceledException and swallowing itLet OperationCanceledException propagate to the caller. Only catch it at the top-level orchestration point where you decide what to do after cancellation (log, clean up, return a result).
Not disposing CancellationTokenSourceCancellationTokenSource is IDisposable. Wrap it in a using statement or dispose it in a finally block. Leaking it causes timer and callback leaks.
Assuming cancellation is immediateCooperative cancellation only takes effect at the next checkpoint. If work items are large or the code has long gaps between checks, cancellation may be delayed. Design checkpoint frequency based on acceptable latency.
Using Thread.Interrupt as a substitute for Thread.AbortThread.Interrupt is also not recommended in modern .NET. It only works on threads in WaitSleepJoin state and throws ThreadInterruptedException, which is a different exception type. Replace with CancellationToken signaling.
Removing ThreadAbortException catch blocks without migrating the cleanup logicThreadAbortException catch blocks often contained critical cleanup (releasing locks, rolling back transactions). Move this logic to finally blocks or CancellationToken.Register callbacks before removing the catch.

More Info

© dotnet, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/dotnet-upgrade/skills/thread-abort-migration of dotnet/skills.

Open the folder on GitHubat commit 8d670fa

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in dotnet/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Thread Abort Migration next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Thread Abort Migration compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Thread Abort Migration this skilldotnet/skills5.6k1 repos~3.2kAutomated safety check: PassMIT
Aspnet Corefanslead/ReverseProxy.Store1632 repos~1.4kAutomated safety check: PassApache-2.0
Prepare Releasemicrosoft/FeatureManagement-Dotnet1.2k—~1.3kAutomated safety check: PassMIT
Aspire Integration TestingDevBetterCom/DevBetterWeb1572 repos~2.3kAutomated safety check: PassNone
Tsp Csharpquerylenshq/ef-querylens225—~1.3kAutomated safety check: PassMIT
Verify Authendpointsmadeyoga/AuthEndpoints121—~2.6kAutomated safety check: PassMIT

Similar skills

  • Aspnet Core

    fanslead/ReverseProxy.Store

    Build, review, refactor, or architect ASP.NET Core web applications using current official guidance for .NET web development.

    163 GitHub starsUsed in 2 repos~1.4k tokens
    Backend & APIsAuto-check passed
  • Prepare Release

    microsoft/FeatureManagement-Dotnet

    Official

    Prepare a release for the Feature Management .NET SDK. An agent skill from microsoft/FeatureManagement-Dotnet.

    1.2k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • Aspire Integration Testing

    DevBetterCom/DevBetterWeb

    Write integration tests using .NET Aspire's testing facilities with xUnit.

    157 GitHub starsUsed in 2 repos~2.3k tokens
    Testing & QAAuto-check passed
  • Tsp Csharp

    querylenshq/ef-querylens

    Comprehensive C and .NET development skill for TSP projects.

    225 GitHub stars~1.3k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Verify Authendpoints

    madeyoga/AuthEndpoints

    Drive the AuthEndpoints HTTP API via the in-repo test host (cookie sessions, Identity bearer, Simple JWT, CSRF, ReAuth).

    121 GitHub stars~2.6k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Dotnet Csharp

    niltor/DeepSeekSDK-NET

    Work on this repository's .NET/C SDK code, including API models, HTTP behavior, Microsoft.Extensions.AI adapters, ASP.NET Core DI, builds, and tests.

    122 GitHub stars~669 tokensUpdated 26 days ago
    Auto-check passed

More from dotnet/skills

All 91 skills in this repo
  • Official

    Resolves .NET runtime frames in Apple .ips crash logs to function names, source files and line numbers using dSYM symbols, atos and the Microsoft symbol server.

    5.6k GitHub starsUsed in 1 repo~2.4k tokens
    Auto-check passed
  • Official

    Resolves native crash frames from .NET Android tombstones to function names, source files and line numbers using BuildIds, Microsoft's symbol server and llvm-symbolizer.

    5.6k GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • Official

    Scans C# and .NET code for about 50 performance anti-patterns and reports prioritized findings with concrete fixes, at a scan depth you choose.

    5.6k GitHub starsUsed in 3 repos~3.1k tokens
    Auto-check passed
  • Official

    Statically pairs source files with test files to list code that no test references, using Roslyn for C# or tree-sitter for many languages, with no build.

    5.6k GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Microbenchmarking

    dotnet/skills

    Official

    Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks.

    5.6k GitHub starsUsed in 3 repos~3.3k tokens
    Auto-check passed
  • Official

    Makes .NET projects compatible with Native AOT and trimming by resolving IL trim and AOT analyzer warnings through annotations rather than suppressions.

    5.6k GitHub starsUsed in 2 repos~4.2k tokens
    Auto-check passed

Questions about Thread Abort Migration

What does Thread Abort Migration do?

Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation in modern .NET. Thread Abort Migration is an agent skill from dotnet/skills, published by the product's own GitHub organization.NET.

When should I use Thread Abort Migration?

Thread Abort Migration fits situations like: : modernizing code that calls Thread.Abort; catching ThreadAbortException; replacing Thread.ResetAbort; replacing Thread.Interrupt for thread termination.

How do I install Thread Abort Migration in Claude Code?

Run `npx skills add dotnet/skills --skill thread-abort-migration -a claude-code`. Or copy the skill folder (plugins/dotnet-upgrade/skills/thread-abort-migration in dotnet/skills) into .claude/skills/thread-abort-migration in your project. Claude Code loads it when a task matches its description.

How do I install Thread Abort Migration in Codex?

Run `npx skills add dotnet/skills --skill thread-abort-migration -a codex`. Or copy the skill folder (plugins/dotnet-upgrade/skills/thread-abort-migration in dotnet/skills) into .agents/skills/thread-abort-migration in your project. Codex loads it when a task matches its description.

Can I use Thread Abort Migration in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dotnet/skills --skill thread-abort-migration -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/thread-abort-migration, .gemini/skills/thread-abort-migration, .github/skills/thread-abort-migration and .opencode/skills/thread-abort-migration in your project.

What does Thread Abort Migration need to run?

SKILL.md names no scripts, command-line tools or credentials: Thread Abort Migration is instructions for the agent only.

Does Thread Abort Migration access the network?

SKILL.md names 1 domain. As links in the text: learn.microsoft.com. This is read from the text; nothing was executed.

Is Thread Abort Migration safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Thread Abort Migration use?

Thread Abort Migration is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Thread Abort Migration use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Thread Abort Migration?

Skills that share tags, products or a category with Thread Abort Migration: Aspnet Core (fanslead/ReverseProxy.Store, 163 stars), Prepare Release (microsoft/FeatureManagement-Dotnet, 1.2k stars), Aspire Integration Testing (DevBetterCom/DevBetterWeb, 157 stars) and Tsp Csharp (querylenshq/ef-querylens, 225 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Thread Abort Migration?

dotnet (a GitHub organization, an official publisher) maintains it in dotnet/skills, which has 5,568 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on October 7, 2026.

Source: dotnet/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.