[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D0VQTFSSF1FEZTF9P7C1G4":3,"skill-same:01M7D0VQTFSSF1FEZTF9P7C1G4":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7D0VQTFSSF1FEZTF9P7C1G4","thread-abort-migration",null,"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.","itsmejay18\u002FAI-Skills-for-My-Development-Stack","itsmejay18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F167779943?v=4","01M7CZRFC6DDZA5V2CX8WDSZED","Jay Jemino Ababon ","01M7CZRFCVRNW1SFHSQXEJ3CQN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fthread-abort-migration\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: thread-abort-migration\ndescription: >\n  Guides migration of .NET Framework Thread.Abort usage to cooperative cancellation\n  in modern .NET.\n  USE FOR: modernizing code that calls Thread.Abort, catching ThreadAbortException,\n  replacing Thread.ResetAbort, replacing Thread.Interrupt for thread termination,\n  resolving PlatformNotSupportedException or SYSLIB0006 after retargeting to .NET 6+,\n  migrating ASP.NET Response.End or Response.Redirect(url, true) which internally\n  call Thread.Abort.\n  DO NOT USE FOR: code that only uses Thread.Join, Thread.Sleep, or Thread.Start\n  without any abort, interrupt, or ThreadAbortException usage — these APIs work\n  identically in modern .NET and need no migration. Also not for projects staying\n  on .NET Framework, or Thread.Abort usage inside third-party libraries you do not\n  control.\nlicense: MIT\n---\n\n# Thread.Abort Migration\n\nThis 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.\n\n## When to Use\n\n- Migrating a .NET Framework project to .NET 6+ that calls `Thread.Abort`\n- Replacing `ThreadAbortException` catch blocks that use control flow or cleanup logic\n- Removing `Thread.ResetAbort` calls that cancel pending aborts\n- Replacing `Thread.Interrupt` for waking blocked threads\n- Migrating ASP.NET code that uses `Response.End` or `Response.Redirect(url, true)`, which internally call `Thread.Abort`\n- Resolving `PlatformNotSupportedException` or `SYSLIB0006` warnings after a target framework change\n\n## When Not to Use\n\n- **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.\n- The project will remain on .NET Framework indefinitely\n- The Thread.Abort usage is inside a third-party library you do not control\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Source project or solution | Yes | The .NET Framework project containing Thread.Abort usage |\n| Target framework | Yes | The modern .NET version to target (e.g., `net8.0`) |\n| Thread.Abort usage locations | Recommended | Files or classes that reference `Thread.Abort`, `ThreadAbortException`, `Thread.ResetAbort`, or `Thread.Interrupt` |\n\n## Workflow\n\n> **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.\n\n### Step 1: Inventory all thread termination usage\n\nSearch the codebase for all thread-termination-related APIs:\n\n- `Thread.Abort` and `thread.Abort()` (instance calls)\n- `ThreadAbortException` in catch blocks\n- `Thread.ResetAbort`\n- `Thread.Interrupt`\n- `Response.End()` (calls Thread.Abort internally in ASP.NET Framework)\n- `Response.Redirect(url, true)` (the `true` parameter triggers Thread.Abort)\n- `SYSLIB0006` pragma suppressions\n\nRecord each usage location and classify the intent behind the abort.\n\n### Step 2: Classify each usage pattern\n\nCategorize every usage into one of the following patterns:\n\n| Pattern | Description | Modern replacement |\n|---------|-------------|--------------------|\n| **Cancellable work loop** | Thread running a loop that should stop on demand | `CancellationToken` checked in the loop |\n| **Timeout enforcement** | Aborting a thread that exceeds a time limit | `CancellationTokenSource.CancelAfter` or `Task.WhenAny` with a delay |\n| **Blocking call interruption** | Thread blocked on `Sleep`, `WaitOne`, or `Join` that needs to wake up | `WaitHandle.WaitAny` with `CancellationToken.WaitHandle`, or async alternatives |\n| **ASP.NET request termination** | `Response.End` or `Response.Redirect(url, true)` | Return from the action method; use `HttpContext.RequestAborted` |\n| **ThreadAbortException as control flow** | Catch blocks that inspect `ThreadAbortException` to decide cleanup actions | Catch `OperationCanceledException` instead, with explicit cleanup |\n| **Thread.ResetAbort to continue execution** | Catching the abort and calling `ResetAbort` to keep the thread alive | Check `CancellationToken.IsCancellationRequested` and decide whether to continue |\n| **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` |\n\n**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.\n\n### Step 3: Apply the replacement for each pattern\n\n- **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()`.\n- **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.\n- **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 })`.\n- **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.\n- **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.\n- **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.\n- **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\u002Fstdout or IPC and calls `Process.Kill` if a timeout expires.\n\n### Step 4: Clean up removed APIs\n\nAfter migrating all patterns, remove or replace any remaining references:\n\n| Removed API | Replacement |\n|-------------|-------------|\n| `Thread.Abort()` | `CancellationTokenSource.Cancel()` |\n| `ThreadAbortException` catch blocks | `OperationCanceledException` catch blocks |\n| `Thread.ResetAbort()` | Check `token.IsCancellationRequested` and decide whether to continue |\n| `Thread.Interrupt()` | Signal via `CancellationToken` or set a `ManualResetEventSlim` (also obsolete: `SYSLIB0046` in .NET 9) |\n| `Response.End()` | Remove the call; return from the method |\n| `Response.Redirect(url, true)` | `Response.Redirect(url)` without endResponse, or return a redirect result |\n| `#pragma warning disable SYSLIB0006` | Remove after replacing the Thread.Abort call |\n\n### Step 5: Verify the migration\n\n1. Build the project targeting the new framework. Confirm zero `SYSLIB0006` warnings and no `Thread.Abort`-related compile errors.\n2. Search the codebase for any remaining references to `Thread.Abort`, `ThreadAbortException`, `Thread.ResetAbort`, or `Thread.Interrupt`.\n3. Run existing tests. If tests relied on `Thread.Abort` for cleanup or timeout, update them to use `CancellationToken`.\n4. For timeout scenarios, verify that work actually stops within a reasonable time after cancellation is requested.\n5. For blocking call scenarios, verify that blocked threads wake up promptly when the token is cancelled.\n\n## Validation\n\n- [ ] No references to `Thread.Abort` remain in the migrated code\n- [ ] No `ThreadAbortException` catch blocks remain\n- [ ] No `Thread.ResetAbort` calls remain\n- [ ] No `SYSLIB0006` pragma suppressions remain\n- [ ] Project builds cleanly against the target framework with no thread-abort-related warnings\n- [ ] All cancellable work accepts a `CancellationToken` parameter\n- [ ] Timeout scenarios use `CancellationTokenSource.CancelAfter` or equivalent\n- [ ] Blocking calls use `WaitHandle.WaitAny` with `token.WaitHandle` or async alternatives\n- [ ] Existing tests pass or have been updated for cooperative cancellation\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Adding `CancellationToken` parameter but never checking it in long-running code | Insert `token.ThrowIfCancellationRequested()` at regular checkpoints in loops and between expensive operations. Cancellation only works if the code cooperates. |\n| Not passing the token through the full call chain | Every 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. |\n| Expecting `CancellationToken` to interrupt blocking synchronous calls like `Thread.Sleep` or `socket.Receive` | These calls do not check the token. Replace `Thread.Sleep(ms)` with `token.WaitHandle.WaitOne(ms)`. Replace synchronous I\u002FO with async overloads that accept a `CancellationToken`. |\n| Catching `OperationCanceledException` and swallowing it | Let `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). |\n| Not disposing `CancellationTokenSource` | `CancellationTokenSource` is `IDisposable`. Wrap it in a `using` statement or dispose it in a `finally` block. Leaking it causes timer and callback leaks. |\n| Assuming cancellation is immediate | Cooperative 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. |\n| Using `Thread.Interrupt` as a substitute for `Thread.Abort` | `Thread.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. |\n| Removing `ThreadAbortException` catch blocks without migrating the cleanup logic | `ThreadAbortException` 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. |\n\n## More Info\n\n- [Thread.Abort breaking change in .NET 6+](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcore\u002Fcompatibility\u002Fcore-libraries\u002F6.0\u002Fthread-abort) — why `Thread.Abort` throws `PlatformNotSupportedException`\n- [Cancellation in managed threads](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fthreading\u002Fcancellation-in-managed-threads) — the cooperative cancellation model with `CancellationToken`\n- [CancellationTokenSource class](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.threading.cancellationtokensource) — API reference for creating and managing cancellation tokens\n- [SYSLIB0006 warning](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Ffundamentals\u002Fsyslib-diagnostics\u002Fsyslib0006) — `Thread.Abort` is obsolete\n- [SYSLIB0046 warning](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Ffundamentals\u002Fsyslib-diagnostics\u002Fsyslib0046) — `Thread.Interrupt` is obsolete (added in .NET 9)\n- [`Task.WaitAsync(CancellationToken)`](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.threading.tasks.task.waitasync) — cancellable waiting for task-based code (.NET 6+)\n","# Thread.Abort Migration\n\nThis 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.\n\n## When to Use\n\n- Migrating a .NET Framework project to .NET 6+ that calls `Thread.Abort`\n- Replacing `ThreadAbortException` catch blocks that use control flow or cleanup logic\n- Removing `Thread.ResetAbort` calls that cancel pending aborts\n- Replacing `Thread.Interrupt` for waking blocked threads\n- Migrating ASP.NET code that uses `Response.End` or `Response.Redirect(url, true)`, which internally call `Thread.Abort`\n- Resolving `PlatformNotSupportedException` or `SYSLIB0006` warnings after a target framework change\n\n## When Not to Use\n\n- **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.\n- The project will remain on .NET Framework indefinitely\n- The Thread.Abort usage is inside a third-party library you do not control\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Source project or solution | Yes | The .NET Framework project containing Thread.Abort usage |\n| Target framework | Yes | The modern .NET version to target (e.g., `net8.0`) |\n| Thread.Abort usage locations | Recommended | Files or classes that reference `Thread.Abort`, `ThreadAbortException`, `Thread.ResetAbort`, or `Thread.Interrupt` |\n\n## Workflow\n\n> **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.\n\n### Step 1: Inventory all thread termination usage\n\nSearch the codebase for all thread-termination-related APIs:\n\n- `Thread.Abort` and `thread.Abort()` (instance calls)\n- `ThreadAbortException` in catch blocks\n- `Thread.ResetAbort`\n- `Thread.Interrupt`\n- `Response.End()` (calls Thread.Abort internally in ASP.NET Framework)\n- `Response.Redirect(url, true)` (the `true` parameter triggers Thread.Abort)\n- `SYSLIB0006` pragma suppressions\n\nRecord each usage location and classify the intent behind the abort.\n\n### Step 2: Classify each usage pattern\n\nCategorize every usage into one of the following patterns:\n\n| Pattern | Description | Modern replacement |\n|---------|-------------|--------------------|\n| **Cancellable work loop** | Thread running a loop that should stop on demand | `CancellationToken` checked in the loop |\n| **Timeout enforcement** | Aborting a thread that exceeds a time limit | `CancellationTokenSource.CancelAfter` or `Task.WhenAny` with a delay |\n| **Blocking call interruption** | Thread blocked on `Sleep`, `WaitOne`, or `Join` that needs to wake up | `WaitHandle.WaitAny` with `CancellationToken.WaitHandle`, or async alternatives |\n| **ASP.NET request termination** | `Response.End` or `Response.Redirect(url, true)` | Return from the action method; use `HttpContext.RequestAborted` |\n| **ThreadAbortException as control flow** | Catch blocks that inspect `ThreadAbortException` to decide cleanup actions | Catch `OperationCanceledException` instead, with explicit cleanup |\n| **Thread.ResetAbort to continue execution** | Catching the abort and calling `ResetAbort` to keep the thread alive | Check `CancellationToken.IsCancellationRequested` and decide whether to continue |\n| **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` |\n\n**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.\n\n### Step 3: Apply the replacement for each pattern\n\n- **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()`.\n- **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.\n- **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 })`.\n- **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.\n- **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.\n- **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.\n- **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\u002Fstdout or IPC and calls `Process.Kill` if a timeout expires.\n\n### Step 4: Clean up removed APIs\n\nAfter migrating all patterns, remove or replace any remaining references:\n\n| Removed API | Replacement |\n|-------------|-------------|\n| `Thread.Abort()` | `CancellationTokenSource.Cancel()` |\n| `ThreadAbortException` catch blocks | `OperationCanceledException` catch blocks |\n| `Thread.ResetAbort()` | Check `token.IsCancellationRequested` and decide whether to continue |\n| `Thread.Interrupt()` | Signal via `CancellationToken` or set a `ManualResetEventSlim` (also obsolete: `SYSLIB0046` in .NET 9) |\n| `Response.End()` | Remove the call; return from the method |\n| `Response.Redirect(url, true)` | `Response.Redirect(url)` without endResponse, or return a redirect result |\n| `#pragma warning disable SYSLIB0006` | Remove after replacing the Thread.Abort call |\n\n### Step 5: Verify the migration\n\n1. Build the project targeting the new framework. Confirm zero `SYSLIB0006` warnings and no `Thread.Abort`-related compile errors.\n2. Search the codebase for any remaining references to `Thread.Abort`, `ThreadAbortException`, `Thread.ResetAbort`, or `Thread.Interrupt`.\n3. Run existing tests. If tests relied on `Thread.Abort` for cleanup or timeout, update them to use `CancellationToken`.\n4. For timeout scenarios, verify that work actually stops within a reasonable time after cancellation is requested.\n5. For blocking call scenarios, verify that blocked threads wake up promptly when the token is cancelled.\n\n## Validation\n\n- [ ] No references to `Thread.Abort` remain in the migrated code\n- [ ] No `ThreadAbortException` catch blocks remain\n- [ ] No `Thread.ResetAbort` calls remain\n- [ ] No `SYSLIB0006` pragma suppressions remain\n- [ ] Project builds cleanly against the target framework with no thread-abort-related warnings\n- [ ] All cancellable work accepts a `CancellationToken` parameter\n- [ ] Timeout scenarios use `CancellationTokenSource.CancelAfter` or equivalent\n- [ ] Blocking calls use `WaitHandle.WaitAny` with `token.WaitHandle` or async alternatives\n- [ ] Existing tests pass or have been updated for cooperative cancellation\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Adding `CancellationToken` parameter but never checking it in long-running code | Insert `token.ThrowIfCancellationRequested()` at regular checkpoints in loops and between expensive operations. Cancellation only works if the code cooperates. |\n| Not passing the token through the full call chain | Every 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. |\n| Expecting `CancellationToken` to interrupt blocking synchronous calls like `Thread.Sleep` or `socket.Receive` | These calls do not check the token. Replace `Thread.Sleep(ms)` with `token.WaitHandle.WaitOne(ms)`. Replace synchronous I\u002FO with async overloads that accept a `CancellationToken`. |\n| Catching `OperationCanceledException` and swallowing it | Let `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). |\n| Not disposing `CancellationTokenSource` | `CancellationTokenSource` is `IDisposable`. Wrap it in a `using` statement or dispose it in a `finally` block. Leaking it causes timer and callback leaks. |\n| Assuming cancellation is immediate | Cooperative 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. |\n| Using `Thread.Interrupt` as a substitute for `Thread.Abort` | `Thread.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. |\n| Removing `ThreadAbortException` catch blocks without migrating the cleanup logic | `ThreadAbortException` 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. |\n\n## More Info\n\n- [Thread.Abort breaking change in .NET 6+](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fcore\u002Fcompatibility\u002Fcore-libraries\u002F6.0\u002Fthread-abort) — why `Thread.Abort` throws `PlatformNotSupportedException`\n- [Cancellation in managed threads](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fstandard\u002Fthreading\u002Fcancellation-in-managed-threads) — the cooperative cancellation model with `CancellationToken`\n- [CancellationTokenSource class](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.threading.cancellationtokensource) — API reference for creating and managing cancellation tokens\n- [SYSLIB0006 warning](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Ffundamentals\u002Fsyslib-diagnostics\u002Fsyslib0006) — `Thread.Abort` is obsolete\n- [SYSLIB0046 warning](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Ffundamentals\u002Fsyslib-diagnostics\u002Fsyslib0046) — `Thread.Interrupt` is obsolete (added in .NET 9)\n- [`Task.WaitAsync(CancellationToken)`](https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.threading.tasks.task.waitasync) — cancellable waiting for task-based code (.NET 6+)\n",{"name":5,"license":15,"description":24},"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.\n","main","30954af1dcd1a74b63f05deb2e2c41e5ecae4a82","02-CSharp-WPF-Desktop-Development\u002Fthread-abort-migration","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack","https:\u002F\u002Fgithub.com\u002Fitsmejay18","2026-09-18 16:06:36",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill thread-abort-migration",{"tool":37,"command":38},"bunx","bunx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill thread-abort-migration",{"tool":40,"command":41},"pnpm","pnpm dlx skills add itsmejay18\u002FAI-Skills-for-My-Development-Stack --skill thread-abort-migration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F02-CSharp-WPF-Desktop-Development\u002Fthread-abort-migration\u002FSKILL.md",true,[],[46,53,60,67,74,81],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7D2RKBHPZ3E1RNN5DWHT550","vectorization","Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64\u002F128\u002F256\u002F512, or platform hardware intrinsics; reviewing existing SIMD code, including Vector\u003CT>, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7D2RDJ7RN3QK8GJR0QTER1D","resolve-project-references","Guide for interpreting ResolveProjectReferences time in MSBuild performance summaries. Activate when ResolveProjectReferences appears as the most expensive target and developers are trying to optimize it directly. Explains that the reported time includes wait time for dependent project builds and is misleading. Guides users to focus on task self-time instead. Do not activate for general build performance -- use build-perf-diagnostics instead.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fresolve-project-references\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7D2R1H2GTNZYHG9YRX3JDQW","optimizing-ef-core-queries","Optimize and improve the performance of slow Entity Framework Core (EF Core) queries: make them generate less SQL, make fewer database round-trips, and return results faster. Use whenever an EF Core or DbContext query or data-access path is slow or should be made faster — whether or not EF Core owns the database schema. For EF Core, not Dapper or raw ADO.NET.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Foptimizing-ef-core-queries\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7D2QREG04W1YT0NEBHEW5C9","microbenchmarking","Activate this skill when BenchmarkDotNet (BDN) is involved in the task — creating, running, configuring, or reviewing BDN benchmarks. Also activate when microbenchmarking .NET code would be useful and BenchmarkDotNet is the likely tool. Consider activating when answering a .NET performance question requires measurement and BenchmarkDotNet may be needed. Covers microbenchmark design, BDN configuration and project setup, how to run BDN microbenchmarks efficiently and effectively, and using BDN for side-by-side performance comparisons. Do NOT use for profiling\u002Ftracing .NET code (dotnet-trace, PerfView), production telemetry, or load\u002Fstress testing (Crank, k6).","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fmicrobenchmarking\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7D2QGE175XWPZVACVH2868Z","incremental-build","Guide for optimizing MSBuild incremental builds. USE FOR: builds slower than expected on subsequent runs, 'nothing changed but it rebuilds anyway', diagnosing why targets re-execute unnecessarily, fixing broken no-op builds. Covers 8 common causes: missing Inputs\u002FOutputs on custom targets, volatile properties in output paths (timestamps\u002FGUIDs), file writes outside tracked Outputs, missing FileWrites registration, glob changes, Visual Studio Fast Up-to-Date Check (FUTDC) issues. Key diagnostic: look for 'Building target completely' vs 'Skipping target' in binlog. DO NOT USE FOR: first-time build slowness (use build-perf-baseline), parallelism issues (use build-parallelism), evaluation-phase slowness (use eval-performance), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Fincremental-build\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7D2Q1DQTC6K49R73WQTTPSB","eval-performance","Guide for diagnosing and improving MSBuild project evaluation performance. USE FOR: builds slow before any compilation starts, high evaluation time in binlog analysis, expensive glob patterns walking large directories (node_modules, .git, bin\u002Fobj), deep import chains (>20 levels), preprocessed output >10K lines indicating heavy evaluation, property functions with file I\u002FO ($([System.IO.File]::ReadAllText(...))), multiple evaluations per project. Covers the 5 MSBuild evaluation phases, glob optimization via DefaultItemExcludes, import chain analysis with \u002Fpp preprocessing. DO NOT USE FOR: compilation-time slowness (use build-perf-diagnostics), incremental build issues (use incremental-build), non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002Fitsmejay18\u002FAI-Skills-for-My-Development-Stack\u002Fblob\u002Fmain\u002F20-Performance-Optimization\u002Feval-performance\u002FSKILL.md",[],[]]