본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)5.8k · #14649

thread-abort-migration

하는 일

이 스킬은 Thread.Abort를 쓰는 .NET Framework 코드를 최신 .NET에서 쓰는 취소 방식으로 옮깁니다. 업그레이드 후 스레드 중단 코드가 더 이상 동작하지 않는 오래된 앱을 옮기는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓.NET 6 이상으로 옮기는 프로젝트가 이제 실패하는 Thread.Abort를 호출할 때.
  • ✓코드가 ThreadAbortException을 잡거나 흐름 제어를 위해 Thread.ResetAbort를 쓸 때.
  • ✓옛 ASP.NET 코드의 Response.End나 Response.Redirect가 최신 .NET에서 동작해야 할 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-upgrade/skills/thread-abort-migration/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-upgrade/skills/thread-abort-migration/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“.NET 8로 올린 뒤 제 코드가 Thread.Abort에서 실패합니다. 이를 취소 방식으로 어떻게 바꿔야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 코드가 Thread.Abort를 쓰는 방식을 찾고, 사용 패턴을 확인하며, 협력적 취소 같은 맞는 대체 방법을 적용합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

Input Required Description
Source project or solution Yes The .NET Framework project containing Thread.Abort usage
Target framework Yes The modern .NET version to target (e.g., net8.0)
Thread.Abort usage locations Recommended Files 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:

Pattern Description Modern replacement
Cancellable work loop Thread running a loop that should stop on demand CancellationToken checked in the loop
Timeout enforcement Aborting a thread that exceeds a time limit CancellationTokenSource.CancelAfter or Task.WhenAny with a delay
Blocking call interruption Thread blocked on Sleep, WaitOne, or Join that needs to wake up WaitHandle.WaitAny with CancellationToken.WaitHandle, or async alternatives
ASP.NET request termination Response.End or Response.Redirect(url, true) Return from the action method; use HttpContext.RequestAborted
ThreadAbortException as control flow Catch blocks that inspect ThreadAbortException to decide cleanup actions Catch OperationCanceledException instead, with explicit cleanup
Thread.ResetAbort to continue execution Catching the abort and calling ResetAbort to keep the thread alive Check CancellationToken.IsCancellationRequested and decide whether to continue
Uncooperative code termination Killing a thread running code that cannot be modified to check for cancellation Move 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: A
자주 묻는 질문

최신 .NET에서도 스레드를 강제로 멈출 수 있나요?

아니요. 최신 .NET은 관리되는 스레드를 강제로 종료하는 것을 지원하지 않으므로, 협력적 취소가 방법입니다.

Thread.Sleep만 쓰는 코드도 바꿔야 하나요?

아니요. Join, Sleep, Start의 단순한 사용은 똑같이 동작하며, 이 경우 마이그레이션이 필요 없다고 스킬이 말합니다.

태스크 현대화도 제안하나요?

선택적인 개선을 제안할 수 있지만, Thread.Abort 수정과는 별개라고 표시합니다.

상세 정보

작성자의 원본 설명

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

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14649
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬